2015-12-01 27 views
0

我有一個文本屏幕在底部和左對齊屏幕和按鈕也是在底部右對齊屏幕。我將尺寸設置爲36 sp,但在Samsung選項卡4 7'(tvdpi)上它看起來很好,但在設備S4(xxhdpi)上,文本位於按鈕後面。我希望文本變得靈活並自行調整。如何使文本看起來像在所有設備的長度(寬度)和高度相同

在我的XML文本視圖是這樣的:

<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,但這也爲我造成了問題。請幫幫我。

回答

0

使用維度文件夾中的文本字體大小和設備大小。

+0

應該評論的傢伙! – Piyush

+0

沒有夥計!它的通用答案! – ManishL

+0

怎麼樣?請定義 –

0

試試這個

<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> 
相關問題