Android 如何在所有设备中使文本在长度(宽度)和高度上看起来相同
我在底部有一个文本屏幕,与屏幕左对齐,按钮也在底部,与屏幕右对齐。我已经给出了36 sp的大小,但在三星tab 4 7(tvdpi)上看起来不错,但在设备S4(xxhdpi)上,文本位于按钮后面。正如我希望文本变得灵活和自我调整 my xml中的文本视图如下所示:Android 如何在所有设备中使文本在长度(宽度)和高度上看起来相同,android,android-layout,textview,android-screen,Android,Android Layout,Textview,Android Screen,我在底部有一个文本屏幕,与屏幕左对齐,按钮也在底部,与屏幕右对齐。我已经给出了36 sp的大小,但在三星tab 4 7(tvdpi)上看起来不错,但在设备S4(xxhdpi)上,文本位于按钮后面。正如我希望文本变得灵活和自我调整 my xml中的文本视图如下所示: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New tools Available"
android:textSize="30sp"
android:textColor="#ffffff"
android:id="@+id/tv_new_tools_available"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:padding="5dp"
android:layout_marginLeft="10dp"/>
我想要的是:
我希望我的文字在所有设备上都看起来很好,不应该和按钮重叠,也应该看起来很好,不应该拧在大设备上,也不应该在小设备上看起来更大
我想知道我如何才能做到这一点,请帮助我,因为我是一个新手在机器人。我做了研究,但发现我应该使用sp而不是dp,但这也给我带来了问题。请帮帮我 使用维度文件夹中的文本字体大小来修改设备大小。试试这个
<LinearLayout
android:id="@+id/ly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:text="TextView"
/>
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Button"
/>
</LinearLayout>
应该是注释都德!不,伙计!这是一般的答案!在res下有不同的Values文件夹,比如res->Values-w->dimens.xml,您必须在其中定义文本字体大小。