В настоящее время я пытаюсь получить свой интерфейс, чтобы иметь панель заголовка, нижнюю панель кнопок, с прокруткой в промежутке между ними. Я могу получить кусочки его работы, но как только я получу другую работу, старая часть возвращается, чтобы не появляться. Вот изображение моего пользовательского интерфейса слева, с тем, что я хочу, чтобы он выглядел справа... (извините за небрежность, я отредактировал его в MS Paint: P)
Чтобы подвести итог, я хочу, чтобы поля Version и Type были перемещены с комнатой для других TextViews в XML файле, и я хочу, чтобы обе кнопки отображались в нижней панели.
РЕДАКТИРОВАТЬ:
Кнопки внизу должны быть равны по размеру, я не слишком талантлив в создании ящиков в MS Paint
EDIT 2: Извините... вот мой XML файл
<?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>
измените кнопки на android:layout_width="wrap_content"
вы также можете ввести значение в sp
или dip
для wrap_content
и добавить в текст android:layout_marginLeft="10sp"
Это должно помочь. Название разделено пробелами, но вы можете сделать что-то немного отличное, чтобы оно выглядело лучше.
Обновлен с дополнением и TableLayout
для TextViews
.
XML:
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4"
android:text="SN: " />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4"
android:text="Test" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4"
android:text="Ver: " />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4"
android:text="Test" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4"
android:text="Type: " />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4"
android:text="Test" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<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="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Read" />
</LinearLayout>
Пример изображения:
TableLayout
. Отредактируйте padding
чтобы лучше понять, какой тип padding
вы хотите и сколько. Вы можете изменить тип заполнения. Есть paddingLeft
, paddingRight ,
paddingTop` и paddingBottom
.
Use
таблицу Layout along with
Table Row, to place both the buttons at the bottom
side to side.
Чтобы исправить кнопки, используйте
android:layout_weight="1"
Я не уверен, как помочь вам в решении других проблем, попробуйте дать им левый запас.