自定义微调-如何?

时间:2018-12-05 15:32:10

标签: android

我正在尝试在Facebook应用程序上创建这样的视图。

facebook example 但是我只有这个

my design 我的老板说这很丑。我已经尝试了所有方法,但是我不知道是哪个视觉元素,也不知道Facebook从何处获得了Android的小部件,它们看起来如此不同或不存在。

我是这样的:

<RelativeLayout
    android:id="@+id/layoutPhone"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="22dp"
    android:layout_marginTop="20dp"
    android:layout_marginEnd="22dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/enterMobileNumber">

    <TextView
        android:id="@+id/country_code"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_marginStart="4dp"
        android:paddingTop="3dp"
        android:paddingBottom="3dp"
        android:text="@string/select_your_country"
        android:textColor="#9B9B9B"
        android:textSize="22sp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_centerVertical="true"
            app:srcCompat="@drawable/ic_sortdown_48px"
            tools:ignore="ContentDescription" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@id/country_code"
            android:background="#737373" />

</RelativeLayout>

有什么方法可以使我获得正确的设计?

1 个答案:

答案 0 :(得分:0)

使用微调器

  <RelativeLayout
        android:id="@+id/layoutPhone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="22dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="22dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/enterMobileNumber">

        <TextView
            android:id="@+id/country_code"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_marginStart="4dp"
            android:paddingTop="3dp"
            android:paddingBottom="3dp"
            android:text="@string/select_your_country"
            android:textColor="#9B9B9B"
            android:textSize="22sp" />

            <Spinner
          android:id="@+id/spinner"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:prompt="@string/spinner_title"/>
    </RelativeLayout>

供您参考https://www.tutorialspoint.com/android/android_spinner_control.htm