Android活动设计
我正在尝试添加两个按钮来注册和登录到UI。问题是,图像与tablelayout不在同一中心,第一个图像获得行的所有宽度 有人能帮我吗 这是密码Android活动设计,android,Android,我正在尝试添加两个按钮来注册和登录到UI。问题是,图像与tablelayout不在同一中心,第一个图像获得行的所有宽度 有人能帮我吗 这是密码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layou
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:gravity="right"
android:orientation="horizontal" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:gravity="right" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right" >
<ImageView
android:id="@+id/ESlanguagebtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:contentDescription="@string/ES_info_pm1"
android:src="@drawable/esp" />
<ImageView
android:id="@+id/ENlanguagebtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:contentDescription="@string/ES_info_pm1"
android:src="@drawable/en" />
<ImageView
android:id="@+id/CATlanguagebtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:contentDescription="@string/ES_info_pm1"
android:src="@drawable/cat" />
<ImageView
android:id="@+id/GAlanguagebtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:contentDescription="@string/ES_info_pm1"
android:src="@drawable/ga" />
<ImageView
android:id="@+id/EUlanguagebtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:contentDescription="@string/ES_info_pm1"
android:src="@drawable/eusk" />
<ImageView
android:id="@+id/PTlanguagebtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:contentDescription="@string/ES_info_pm1"
android:src="@drawable/por" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/roundcorners"
android:paddingBottom="20dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingTop="20dp" >
<TableRow>
<TextView
android:id="@+id/Textheadwelcome"
android:layout_gravity="left"
android:text="@string/ES_bienvenida"
android:textColor="#000000"
android:textSize="30sp" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/Textheadwelcome2"
android:layout_width="match_parent"
android:layout_gravity="left"
android:text="@string/ES_bienvenida2"
android:textColor="#000000"
android:textSize="15sp" />
</TableRow>
<TableRow>
<ImageView
android:id="@+id/logireg"
android:layout_width="wrap_content"
android:src="@drawable/registrarse1" />
<ImageView
android:id="@+id/loginit"
android:layout_width="wrap_content"
android:src="@drawable/login1" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
以及活动的屏幕截图
删除线性布局上父元素中的android:layout\u权重,然后将权重1添加到两个imageview中 那应该把他们排好
也考虑DOIN相对布局代替嵌套表,可以得到一点性能提升。
:
<TableRow android:weightSum="2" >
<ImageView
android:id="@+id/logireg"
android:layout_width="wrap_content"
android:src="@drawable/registrarse1" android:layout_weight="1" android:layout_gravity="center"/>
<ImageView
android:id="@+id/loginit"
android:layout_width="wrap_content"
android:src="@drawable/login1" android:layout_weight="1" android:layout_gravity="center"/>
</TableRow>
试试这个
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingTop="20dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/Textheadwelcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="@string/ES_bienvenida"
android:textColor="#000000"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/Textheadwelcome2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="@string/ES_bienvenida2"
android:textColor="#000000"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" >
<ImageView
android:id="@+id/logireg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/registrarse1" />
<ImageView
android:id="@+id/loginit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/login1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>.
.
或
Hi,这对我很有用,但是,每个图像的权重如何影响未定义权重的行?
<TableRow>
<ImageView
android:id="@+id/logireg"
android:layout_width="0dp" //Use width as 0dp
android:layout_gravity="center" // and gravity as center
android:layout_weight="1" // Add weight as 1
android:src="@drawable/registrarse1" />
<ImageView
android:id="@+id/loginit"
android:layout_width="0dp" //Use width as 0dp
android:layout_gravity="center" // and gravity as center
android:layout_weight="1" // Add weight as 1
android:src="@drawable/login1" />
</TableRow>