Я пишу приложение для Android. Вот его макет XML:
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left|top|bottom|right"
android:layout_marginTop="80dip"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginBottom="60dip"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/centerlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left|right|top|bottom"
android:layout_marginRight="20dip"
android:layout_marginLeft="10dip"
android:layout_marginBottom="120dip" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow>
<Button android:text="Button"
android:layout_column="0"
android:id="@+id/bookmarkbutton"
android:layout_width="230dip"
android:layout_height="30dip"
android:background="@drawable/red_btn"
android:padding="14dp"
></Button>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
и если я запускаю его, он отображает следующий экран:
Но когда я добавляю android:layout_gravity="left" к "Кнопке", размер кнопки уменьшается и показывает:
Обратите внимание, если я изменяю ширину кнопки на android:layout_width="30dip", она показывает маленькие кнопки,
но если я изменю его на больший размер, он не применит размер правильно, а максимальная ширина будет такой же, как у второго изображения.
Наконец, если я добавлю к нему новое текстовое представление, через
ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left|top|bottom|right"
android:layout_marginTop="80dip"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginBottom="60dip"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/centerlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left|right|top|bottom"
android:layout_marginRight="20dip"
android:layout_marginLeft="10dip"
android:layout_marginBottom="120dip"
>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/subjecttext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingExtra="10dip"
android:padding="14dp"
/>
</TableRow>
<TableRow>
<Button android:text="Button"
android:layout_column="0"
android:id="@+id/bookmarkbutton"
android:layout_width="20dip"
android:layout_height="30dip"
android:background="@drawable/black_btn"
android:padding="14dp"
></Button>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
Он отображает следующее изображение, и размер кнопки больше не изменяется. Не могли бы вы сказать мне, что случилось?