Android 如何使此滚动布局工作?
我目前正试图让我的UI有一个标题栏,一个底部按钮栏,中间有一个滚动视图。我可以让它的一部分一部分的工作,但一旦我得到一个不同的工作,旧的部分回到没有出现。左边是我的UI图片,右边是我希望它看起来像什么……很抱歉,我在MS Paint:P中编辑了它 总而言之,我希望版本和类型字段能够移动,并为XML文件中的其他文本视图留出空间,我希望这两个按钮都显示在底部栏上 编辑: 底部的按钮大小应该相等,我不太擅长用MS Paint制作盒子 编辑2: 对不起……这是我的XML文件Android 如何使此滚动布局工作?,android,user-interface,Android,User Interface,我目前正试图让我的UI有一个标题栏,一个底部按钮栏,中间有一个滚动视图。我可以让它的一部分一部分的工作,但一旦我得到一个不同的工作,旧的部分回到没有出现。左边是我的UI图片,右边是我希望它看起来像什么……很抱歉,我在MS Paint:P中编辑了它 总而言之,我希望版本和类型字段能够移动,并为XML文件中的其他文本视图留出空间,我希望这两个按钮都显示在底部栏上 编辑: 底部的按钮大小应该相等,我不太擅长用MS Paint制作盒子 编辑2: 对不起……这是我的XML文件 <?xml versi
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="SN : " />
<TextView
android:id="@+id/serialNumberView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Ver : " />
<TextView
android:id="@+id/versionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Type : " />
<TextView
android:id="@+id/typeView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<CheckBox
android:id="@+id/floatCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Float" />
<CheckBox
android:id="@+id/tripCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trip" />
<CheckBox
android:id="@+id/closeCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Close" />
<CheckBox
android:id="@+id/blockedCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blocked" />
<CheckBox
android:id="@+id/hardTripCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hard Trip" />
<CheckBox
android:id="@+id/phaseAngleCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phase angle wrong for closing" />
<CheckBox
android:id="@+id/diffVoltsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Differential volts too low" />
<CheckBox
android:id="@+id/networkVoltsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Network volts too low to close" />
<CheckBox
android:id="@+id/usingDefaultsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Using Defaults( Reprogram )" />
<CheckBox
android:id="@+id/relaxedCloseActiveCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relaxed Close Active" />
<CheckBox
android:id="@+id/commBoardDetectedCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comm Board Detected" />
<CheckBox
android:id="@+id/antiPumpBlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Anti-Pump Block" />
<CheckBox
android:id="@+id/motorCutoffCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motor Cutoff Inhibit" />
<CheckBox
android:id="@+id/phaseRotationCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phase Rotation Wrong" />
<CheckBox
android:id="@+id/usingDefaultDNPCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text= "Using Default DNP Profile" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Back" />
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Read" />
</LinearLayout>
</LinearLayout>
试试这个
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="9"
android:gravity="center"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="SN : "
android:layout_weight="1" />
<TextView
android:id="@+id/serialNumberView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_weight="2"
android:text="saasdasd ssadasd sadas asd sd sd"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Ver : "
android:layout_weight="1" />
<TextView
android:id="@+id/versionView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text="saasdasd ssadasd sadas asd sd sd"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Type : "
android:layout_gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="@+id/typeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text="saasdasd ssadasd sadas asd sd sd" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<CheckBox
android:id="@+id/floatCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Float" />
<CheckBox
android:id="@+id/tripCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trip" />
<CheckBox
android:id="@+id/closeCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Close" />
<CheckBox
android:id="@+id/blockedCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blocked" />
<CheckBox
android:id="@+id/hardTripCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hard Trip" />
<CheckBox
android:id="@+id/phaseAngleCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phase angle wrong for closing" />
<CheckBox
android:id="@+id/diffVoltsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Differential volts too low" />
<CheckBox
android:id="@+id/networkVoltsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Network volts too low to close" />
<CheckBox
android:id="@+id/usingDefaultsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Using Defaults( Reprogram )" />
<CheckBox
android:id="@+id/relaxedCloseActiveCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relaxed Close Active" />
<CheckBox
android:id="@+id/commBoardDetectedCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comm Board Detected" />
<CheckBox
android:id="@+id/antiPumpBlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Anti-Pump Block" />
<CheckBox
android:id="@+id/motorCutoffCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motor Cutoff Inhibit" />
<CheckBox
android:id="@+id/phaseRotationCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phase Rotation Wrong" />
<CheckBox
android:id="@+id/usingDefaultDNPCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text= "Using Default DNP Profile" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Back"
android:layout_weight=".5" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Read"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
试试这个
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="9"
android:gravity="center"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="SN : "
android:layout_weight="1" />
<TextView
android:id="@+id/serialNumberView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_weight="2"
android:text="saasdasd ssadasd sadas asd sd sd"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Ver : "
android:layout_weight="1" />
<TextView
android:id="@+id/versionView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text="saasdasd ssadasd sadas asd sd sd"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Type : "
android:layout_gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="@+id/typeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text="saasdasd ssadasd sadas asd sd sd" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<CheckBox
android:id="@+id/floatCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Float" />
<CheckBox
android:id="@+id/tripCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trip" />
<CheckBox
android:id="@+id/closeCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Close" />
<CheckBox
android:id="@+id/blockedCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blocked" />
<CheckBox
android:id="@+id/hardTripCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hard Trip" />
<CheckBox
android:id="@+id/phaseAngleCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phase angle wrong for closing" />
<CheckBox
android:id="@+id/diffVoltsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Differential volts too low" />
<CheckBox
android:id="@+id/networkVoltsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Network volts too low to close" />
<CheckBox
android:id="@+id/usingDefaultsCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Using Defaults( Reprogram )" />
<CheckBox
android:id="@+id/relaxedCloseActiveCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relaxed Close Active" />
<CheckBox
android:id="@+id/commBoardDetectedCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comm Board Detected" />
<CheckBox
android:id="@+id/antiPumpBlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Anti-Pump Block" />
<CheckBox
android:id="@+id/motorCutoffCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motor Cutoff Inhibit" />
<CheckBox
android:id="@+id/phaseRotationCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phase Rotation Wrong" />
<CheckBox
android:id="@+id/usingDefaultDNPCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text= "Using Default DNP Profile" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Back"
android:layout_weight=".5" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Read"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
将按钮更改为android:layout\u width=wrap\u content
您还可以在sp或dip中为包裹内容输入值
并在文本中添加android:layout\u marginLeft=10sp将按钮更改为android:layout\u width=wrap\u content
您还可以在sp或dip中为包裹内容输入值
并在文本android:layout_marginLeft=10sp处添加,以修复使用的按钮
android:layout_weight="1"
我不知道如何帮助您解决其他问题,请尝试给它们留一些空白。要修复按钮,请使用
android:layout_weight="1"
我不知道如何帮助您解决其他问题,请尝试给它们留一些空白。使用表格布局和表格行将两个按钮放置在底部对侧。使用表格布局和表格行将两个按钮放置在底部对侧。这应该会有所帮助。标题用空格隔开,但是你可以做一些不同的事情使它看起来更好 更新了文本视图的填充和表格布局 XML: 示例图片:
这应该会有所帮助。标题用空格隔开,但是你可以做一些不同的事情使它看起来更好 更新了文本视图的填充和表格布局 XML: 示例图片:
还有什么需要的吗?这对按钮很有效,但现在3个文本视图的文本居中,而3个没有文本的视图仍然隐藏。我要做的是将这些文本视图留空,因为当用户按下底部的“读取”按钮时,它将从另一个设备读取并显示该设备的信息。我希望已经有了空间,这样在加载文本时东西不会移动太多。可以使用android:layout\u weight,并根据每个人的需要设置权重……。我不明白你的意思,按钮现在很完美。我会把他们的体重设定为多少?我唯一一次看到权重被设置为1.0,你还需要什么吗?这对按钮来说效果很好,但现在3个文本视图的文本居中,而3个没有文本的视图仍然隐藏。我要做的是将这些文本视图留空,因为当用户按下底部的“读取”按钮时,它将从另一个设备读取并显示该设备的信息。我希望已经有了空间,这样在加载文本时东西不会移动太多。可以使用android:layout\u weight,并根据每个人的需要设置权重……。我不明白你的意思,按钮现在很完美。我会把他们的体重设定为多少?我唯一一次看到使用的权重是将其设置为1.0。我希望6个文本视图沿视图宽度均匀分布,并在TableLayout中添加更好的间距。编辑填充以更好地了解您想要的填充类型或填充量。您可以更改填充类型。有paddingLeft、paddingRight、paddingTop`和paddingBottom。但是这个实现不会处理文本视图的最坏情况。就像Dheeresh Singh的回答一样。我使用的是Dheeresh发布的内容,但感谢您的输入。我希望6个文本视图沿视图宽度均匀分布,并在TableLayout中添加一些更好的间距。编辑填充以更好地了解您想要的填充类型或填充量。您可以更改填充类型。有paddingLeft、paddingRight、paddingTop`和paddingBottom。但是这个实现不会处理文本视图的最坏情况。就像德雷什·辛格的回答。我使用的是德雷什发布的内容,谢谢你的输入。