两个导叶棒形成L?

时间:2014-08-31 13:15:26

标签: android seekbar

我是Android的新手,可能不知道所有选项。任何帮助表示赞赏。

指定"%屏幕宽度"的正确方法是什么?和"屏幕长度的百分比"?哪种布局是正确的?

我试图在屏幕的左侧20%处设置一个垂直线,在屏幕底部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>

1 个答案:

答案 0 :(得分:0)

这有助于您走上正轨。出于某种原因,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>
相关问题