2014-01-23 49 views
0

header placement固定用戶界面兼容所有類型的屏幕在單一佈局

我想使標題放置在其背景附近。我需要使視圖與所有屏幕兼容,而不使用固定的像素值。

幫我解決這個問題。

+0

您指的是帶有文本「Save $ 150」的灰色元素?與alignLeft的相對佈局怎麼樣? – MikeIsrael

+0

您如何使用?你在哪裏使用?任何XML細節請..給一些適當的問題 –

+0

請看看這個** http://mobile.smashingmagazine.com/2012/07/26/android-design-tips/** – deniz

回答

1

您可以通過給體重將屏幕分爲兩部分。 How ..?

這是XML代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="6"> 

    <LinearLayout 
     android:id="@+id/headerlayout" 
     android:layout_weight="1" 
     android:layout_height="0dp" 
     android:layout_width="fill_parent" 
     android:background="#ffff00"></LinearLayout> 
    <LinearLayout 
     android:id="@+id/baselayout" 
     android:layout_weight="5" 
     android:layout_height="0dp" 
     android:layout_width="fill_parent" 
     android:background="@android:color/darker_gray"></LinearLayout> 

    </LinearLayout> 

在那裏,你會發現一個佈局,是黃色的顏色可以在你的代碼頭行事。它對所有設備都會起作用。您可以根據您的需求增加或減少佈局的重量,就像您想要的標題一樣。