2014-08-31 19 views
1

我是Android的新手,可能不知道所有選項。任何幫助表示讚賞。兩個seekbars形成一個L?

指定「屏幕寬度百分比」和「屏幕長度百分比」的正確方法是什麼?哪種佈局是正確的?

我試圖做一個垂直在屏幕的左邊20%和一個水平seekbar在底部的20%的屏幕與其餘的由80%-80%象限形成的圖像。

<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:layout_marginLeft="10dp" 
android:orientation="vertical" 
android:stretchColumns="*" 
tools:context=".MainActivity" > 

<TextView 
    android:id="@+id/title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/text_title"/> 

<SeekBar 
    android:id="@+id/seekBar2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="false" 
    android:layout_alignParentTop="false" 
    android:hapticFeedbackEnabled="true" 
    android:progress="25" /> 

<ImageView /> 

<SeekBar 
    android:id="@+id/seekBar1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:hapticFeedbackEnabled="true" 
    android:progress="50" 
    android:rotation="270" /> 

</RelativeLayout> 

回答

0

這將幫助你在正確的軌道上:

可以肯定的,下面沒有因爲seekbars中間來堅定服務宗旨。由於某種原因,android並沒有轉動寬度和高度屬性,所以它只是轉動視圖。所以如果你改變垂直搜索欄的寬度,它會變得更小,就好像它仍然是水平的。我相信有人有更好的方法或解決這個問題的方法,但我現在不能在這方面花費太多時間。後來我可以,然後我會檢查它,但現在這個工程 - 是啊。

我收錄了我的圖片。突出顯示的藍色是圖像視圖。

尺寸基於nexus 5 1080x1776(不包括頂部有時間和通知的東西)。

編輯:

通常情況下,你沒有寬度和高度使用X%。我使用像素是因爲我爲特定設備(如Nexus 5)設計的。我認爲不是包裝,匹配或填充的正常寬度和高度是em?還是dp?這是這樣的。其他人可以告訴你,或者你可以查看它。

您選擇了正確的佈局。正如我所描述的,相對佈局是視圖相對於其他視圖的位置。它基本上放置在任何地方。線性佈局被堆疊。每個視圖都會跟着另一個。

vertical seekbar

<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:layout_marginLeft="10dp" 
    android:orientation="vertical" 
    android:stretchColumns="*" 
    tools:context=".MainActivity" > 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Test Here"/> 

    <SeekBar 
     android:id="@+id/seekBar2" 
     android:layout_width="match_parent" 
     android:layout_height="335.2px" 
     android:layout_alignParentTop="false" 
     android:hapticFeedbackEnabled="true" 
     android:progress="25" /> 

    <SeekBar 
     android:id="@+id/seekBar1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:hapticFeedbackEnabled="true" 
     android:progress="50" 
     android:rotation="270" 
     android:layout_below="@+id/seekBar2"/> 

    <ImageView 
     android:layout_width="864px" 
     android:layout_height="1420.8px" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" 
     android:layout_below="@+id/seekBar2" 
     android:id="@+id/imageView" /> 
</RelativeLayout>