2013-10-03 71 views
-3

如何使佈局與普通屏幕和平板電腦屏幕相同? 我可以改變線性佈局與相同的空間和peding嗎?請幫助我的新:) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx the photo explain my problem 如何使相對佈局容納平板電腦屏幕

家庭代碼是

<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:background="@drawable/backr" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".FreeDENTAL" > 

    <Button 
     android:id="@+id/buttonlec" 
     android:layout_width="fill_parent" 
     android:layout_height="100dp" 
     android:layout_alignBottom="@+id/buttonbook" 
     android:layout_alignLeft="@+id/buttonbook" 
     android:layout_marginBottom="47dp" 
     android:background="@drawable/cooltext1218143078" /> 

<Button 
    android:id="@+id/buttonbook" 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="158dp" 
    android:background="@drawable/cooltext1218138491" /> 

<Button 
    android:id="@+id/button1" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="50dp" 
    android:layout_alignLeft="@+id/buttonbook" 
    android:layout_alignRight="@+id/buttonbook" 
    android:layout_below="@+id/buttonlec" 
    android:layout_marginTop="18dp" 
    android:background="@drawable/cooltext1218134039" /> 

<Button 
    android:id="@+id/button2" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="160dp" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/button1" 
    android:layout_below="@+id/button1" 
    android:layout_marginTop="32dp" 
    android:background="@drawable/cooltext1218152696" /> 

<Button 
    android:id="@+id/button4" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/button2" 
    android:layout_alignRight="@+id/button2" 
    android:layout_below="@+id/button2" 
    android:background="@drawable/tips" 
    /> 

<Button 
    android:id="@+id/button5" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBaseline="@+id/button2" 
    android:layout_alignBottom="@+id/button2" 
    android:layout_alignLeft="@+id/button3" 
    android:layout_alignRight="@+id/button1" 
    android:background="@drawable/news" /> 

<Button 
    android:id="@+id/button3" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="125dp" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/button4" 
    android:layout_alignRight="@+id/button1" 
    android:layout_below="@+id/button2" 
    android:background="@drawable/cooltext1218061123" /> 

</RelativeLayout> 

回答

0

嘗試用android:layout_weight,而不是固定的DP工作。

由於可以在這裏看到: Percentage width in a RelativeLayout

+0

android:layout_weight使用linearlayout我想要相對和相同的按鈕之間的空格 – Abdwo

+0

我可以在相對的一個裏面使用線性佈局嗎?如何 – Abdwo

+0

是的,這是可能的,一個例子可以在這裏找到:http://stackoverflow.com/questions/17220695/how-can-i-nest-a-linear-layout-inside-a-relative-layout-to- achive-the-desired-ui – Enigma

0

檢查dimen.xmlvalues-sw600dp

android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 

OR values-sw720dp文件夾: 可嘗試改變 變化

android:layout_width="match_parent" 
android:layout_height="match_parent" 

TO

android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
+1

fill_parent在版本8和更高版本中被棄用,更喜歡match_parent – Enigma

+0

@check更新的答案 –

+0

不起作用可以添加更多詳細信息嗎? – Abdwo

0

從技術上講,你有兩個屏幕上的佈局相同。在平板電腦上看起來很奇怪的一些原因是:

  1. 它看起來不像你有不同的屏幕尺寸不同的按鈕圖像。
  2. 對於頂部按鈕的寬度,您正在使用fill_parent - 考慮到可能的各種屏幕尺寸,這可能最終會在至少幾個屏幕上擴展它們。

我建議閱讀Supporting Multiple Screens指南。