簡體   English   中英

如何使文本在所有設備中的長度(寬度)和高度看起來都一樣

[英]How to make Text to look like same with respect to length (width) and height in all devices

我在底部有一個文本屏幕,並與屏幕左對齊,在底部也有一個按鈕,與屏幕右對齊。 我給出的大小為36 sp,但是在Samsung選項卡4 7'(tvdpi)上看起來不錯,但是在設備S4(xxhdpi)上,文本位於按鈕后面。 我希望文本在哪里變得靈活並自行調整。

我的xml中的T​​ext視圖是這樣的:

<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"/>

我想要的是 :

我希望我的文字在所有設備上都應該看起來不錯,並且不應該與按鈕重疊,並且應該看起來不錯,而不是在大型設備上擰緊,並且在小型設備上也應該看起來不大

我想知道如何實現此目標,因為我是android的新手,所以請幫助我。 我做了有關方面的研究,但是發現我應該使用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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM