#android
#Android
Вопрос:
Когда я меняю ориентацию макета, приложение вылетает в симуляторе??
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"><View android:layout_width="fill_parent" android:layout_height="10dp"></View><TableLayout android:layout_width="fill_parent"
android:layout_height="150dp" android:background="@drawable/table_one">
<TableRow android:layout_height="20dp" android:layout_width="fill_parent">
<View android:layout_height="20dp" android:layout_width="fill_parent"></View></TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="40dp"><TextView android:gravity="center|left"android:layout_width="70dp" android:layout_height="40dp"
android:textColor="#000000" android:text="Name"
android:layout_marginLeft="4dp" android:layout_weight="20" />
<Spinner android:id="@ id/Spinner01" android:gravity="center"
android:layout_width="250dp" android:layout_height="40dp"
android:layout_marginRight="5dp" android:layout_weight="80"></Spinner>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="40dp">
<TextView android:gravity="center|left" android:textColor="#000000"
android:layout_alignParentLeft="true" android:layout_width="70dp"
android:layout_height="40dp" android:layout_weight="30"
android:text="Status :" android:layout_marginLeft="4dp" />
<TextView android:id="@ id/Spinner01" android:layout_width="250dp"
android:layout_height="40dp" android:layout_weight="70"
android:layout_marginRight="5dp"></TextView>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="40dp">
<TextView android:gravity="center|left" android:textColor="#000000"
android:layout_width="70dp" android:layout_height="40dp"
android:layout_weight="30" android:text="Type :"
android:layout_marginLeft="4dp" />
<TextView android:textColor="#250517"
android:layout_gravity="center" android:id="@ id/Spinner01"
android:layout_width="250dp" android:layout_height="40dp"
android:layout_weight="70" android:layout_marginRight="5dp"></TextView>
</TableRow>
</TableLayout>
<View android:layout_width="fill_parent" android:layout_height="10dp"></View>
<TableLayout android:layout_width="fill_parent"
android:background="@drawable/table_one" android:layout_height="90dp">
<TableRow android:layout_height="20dp">
<View android:layout_height="20dp"></View>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="40dp">
<TextView android:gravity="center|left" android:textColor="#000000"
android:layout_height="40dp" android:layout_weight="20"
android:text="Document" android:layout_marginLeft="4dp"
android:layout_width="70dp" />
<EditText android:id="@ id/btn_browse" android:singleLine="true" android:layout_width="100dp"
android:layout_height="40dp" android:layout_weight="80"
android:layout_marginRight="5dp"></EditText>
</TableRow>
</TableLayout>
<View android:layout_width="fill_parent" android:layout_height="10dp"></View>
<TableLayout android:orientation="horizontal"
android:background="@drawable/my_bsckround" android:layout_width="fill_parent"
android:gravity="center_vertical" android:layout_height="160dp">
<TableRow android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:text="Print" android:id="@ id/btn_print"
android:layout_width="106dp" android:layout_height="wrap_content"></Button>
<Button android:text="Settings" android:id="@ id/btn_setting"
android:layout_width="106dp" android:layout_height="wrap_content"></Button>
<Button android:text="Cancel" android:id="@ id/btn_cncl"
android:layout_width="106dp" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
<View android:layout_width="fill_parent" android:layout_height="10dp"></View>
Комментарии:
1. в чем ошибка logcat?. Кроме того, какую android: ориентацию вы имеете в виду? у вас есть в базе LinearLayout и TableLayout.
2. Base — это линейное описание..
Ответ №1:
Пожалуйста, используйте
<activity android:name=".ShareTweet" android:label="@string/app_name"
android:screenOrientation="portrait" />
чтобы создать идеальный код.
Комментарии:
1. я думаю, что с моим макетом что-то не так .. вы можете это проверить
2. Приведенный выше код поможет вам настроить ориентацию экрана только в портретном режиме. Это постоянно,
Ответ №2:
При повороте экрана действие создается снова. Найдите проблему в своем методе onCreate ().
Ответ №3:
я надеюсь, что это поможет вам. Добавьте это с классом activity в файл манифеста
android:configChanges="orientation|keyboardHidden">