設定方法の異なるレイアウトに1XMLファイルをAndroid
-
26-09-2019 - |
質問
こんにちは友人の私自のレイアウトスTabLayout内LinearLayoutも私のボタンを終了できない正しく設定していTabLayout分のすべてのフィールドの列数では誰でもできるので助の設定方法は2つのレイアウトを一つのXMLファイル すべての分野にTabLayout、残りの両方のログインし、登録ボタンを直線レイアウトの鉱石その他のように設定します。
よろしくお願いします。
レイアウト
ユーザー名!EditTextBox
パスワード!EditTextBox
ログイン!登録
ボタンを押すだけ!ボタン
の気持ちを抱いて欲しいと思いレイアウト上の形式で利用していTabLaoutその場合はそのことが私のボタンのコンビニ等もあるのでゆったりとしてストレッチングでボタンひとつ以上のその他の一つとしてEditText以TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="26sp"
android:text="@string/login_text"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow>
<TextView
android:layout_width="120px"
android:text="User name"
/>
<EditText
android:id="@+id/txtUserName"
android:singleLine="true"
android:maxLength="20"
android:width="195px"
/>
</TableRow>
<TableRow>
<TextView
android:layout_width="120px"
android:text="Password"
/>
<EditText
android:id="@+id/txtPassword"
android:width="195px"
android:maxLength="20"
android:singleLine="true"
android:password="true"
/>
</TableRow>
<TableRow>
<TextView />
<CheckBox android:id="@+id/chkRememberPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Remember Password"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/buttonRegister"
android:text="Register"
android:layout_width="124px"
android:layout_height="wrap_content"
android:layout_below="@+id/chkRememberPassword"
android:layout_alignRight="@+id/chkRememberPassword"
/>
<Button
android:id="@+id/buttonSignIn"
android:text="Log In"
android:layout_width="124px"
android:layout_height="wrap_content"
android:layout_below="@+id/chkRememberPassword"
android:layout_alignLeft="@+id/chkRememberPassword"
/>
</TableRow>
<TextView
android:id="@+id/statusError"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</TableLayout>
</LinearLayout>
解決
私はあなたがTableLayoutでwrap_contentを使用すると、あなたはのLinearLayoutであなたのボタンを持つことができます示唆
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
他のヒント
単一のXMLファイルに複数のレイアウトを設定する
そのことはできません...そして、同じ理由でAndroidはなど、レイアウト、レイアウト-風景を、持っているフォルダシステムの種類..
100rabhで説明したように、あなたが何ができるか相対的なレイアウトとフィル親の設定を適用することにより、ユニバーサルレイアウトを作る...です...
私はあなたが2つのXMLレイアウトファイルを作成し、レイアウト、景観フォルダ内の風景のレイアウトを配置する必要が説明したようにそうでなければ、それによってそれぞれのレイアウトが自動的に携帯電話の向きに応じて設定されます...
希望このことができますU ...
を作成する必要があり2つのXMLファイル:
- 一つは、通常の
layout
フォルダ - 第二に
res/layout-land
を定義するレイアウトの風景。して作成していただく必要があり、res/layout-land
フォルダにない場合はすでに存在しています。
所属していません StackOverflow