【问题标题】:How to draw horizontal line and place slide up or slide down icon end of the layout?如何绘制水平线并将上滑或下滑图标放在布局的末尾?
【发布时间】:2017-03-15 12:29:00
【问题描述】:

我正在 android 中创建上滑和下滑选项。我想绘制水平线并将LinearLayout 的向上或向下滑动图标末端放置。 我使用了layout_weight 概念。但图标大小会因屏幕大小而异。 enter image description here

    `<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="end"
        android:weightSum="15"
        >

        <View
            android:background="@color/blue_tint"
            android:layout_width="0dp"
            android:layout_height="5dp"
            android:layout_gravity="center"
            android:layout_weight="14"
            />
        <TextView
            android:id="@+id/slide_button"
            android:background="@drawable/ic_menu_slide_down"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:textStyle="bold"
            android:textSize="20sp"
            android:paddingStart="5dp"
            android:paddingEnd="5dp"
            android:layout_weight="1"
            />
    </LinearLayout>`

【问题讨论】:

  • 在此处发布您的完整布局代码

标签: android android-layout material-design


【解决方案1】:

根据“给定图像”的线条和图像

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical">
    <view
        android:layout_width="0dp"
        android:layout_height="2dp"
        android:background="#000"
        android:layout_weight="1"/>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_report_image"
        />
</LinearLayout>   

【讨论】:

    猜你喜欢
    • 2013-01-06
    • 1970-01-01
    • 2011-05-16
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多