如何设置不同的布局,在1XML文件在安卓
-
26-09-2019 - |
题
嗨,朋友们我已将我的布局通过TabLayout内LinearLayout但是我的按钮在结束时不能适当地设定为TabLayout分歧的所有领域中的列数因此任何人都可以帮助如何设置2布局,在一个XML文件 意味着所有领域中TabLayout和剩余的两个登录和登记册按钮在线性布局矿石的一些其他,以便他们可以设置正常。
在此先感谢。
布局
用户名!EditTextBox
密码!EditTextBox
登录!注册
按钮!按钮
我想我的布局在上述格式所以我们用TabLaout但在这种情况下,这是引起我的按钮认为这是伸展一个按钮比另一个作为EditText大于控
<?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>
解决方案
我建议你使用WRAP_CONTENT在TableLayout&然后你可以在你的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布局文件,并将该布局布局,景观文件夹,从而相应的布局会自动根据手机...
的方向来设置景观希望这有助于ü...
你需要创建2XML文件:
- 一个在正常
layout
文件夹 - 第二,在一个
res/layout-land
定义的布局的横向。你会需要创造res/layout-land
文件夹,如果它已经不存在。
不隶属于 StackOverflow