2014-08-31 58 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>