现在,我的登录按钮比我的应用程序名称文本更宽,因为它使用固定的相对布局填充,但我希望它自动扩展到行与应用程序名称文本的左边缘和右边缘对齐。有没有什么办法以编程方式做到这一点?使按钮宽度等于Android上的不同文本宽度(不是按钮的文本)Android
我希望它在所有设备上看起来都一样。我担心,如果我只是硬编码自己的页边空白,它会在我的设备上看起来很正确,但如果它们呈现不同的字体,可能无法在其他设备上正确显示。
谢谢!
layout.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@drawable/back_image"
android:padding="20dp" >
<TextView
android:id="@+id/AppNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin_top"
android:fontFamily="Arial"
android:text="@string/app_title"
android:textColor="@color/white"
android:textSize="@dimen/text_size" />
<com.timey.widget.Button
android:id="@+id/signInButton"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="@color/green"
android:fontFamily="Arial"
android:text="@string/sign_in"
android:textColor="@color/white"
android:textSize="30sp" />
</RelativeLayout>
样机用红色虚线说明我多么希望应用程序名称的两侧的我的登录按钮两侧排队:
尝试使用线性布局 – Nabin 2014-08-28 01:46:32
这将如何使它们具有相同的宽度? – 2014-08-28 01:48:38
等待给你答案 – Nabin 2014-08-28 01:49:38