相关疑难解决方法(0)

材料设计 - 操作栏标题和内容的左边距不匹配

我正在尝试按照布局指南- 指标和线条设置屏幕边距.具体而言,移动屏幕上的列表内容应具有72 dp的边距,并与指南中所示的标题一致:

在此输入图像描述

由于Android Studio会自动在res/dimens.xml中生成边距值,我认为我会通过添加自己的"内部"边距来使我的内容与标题保持一致:

dimens.xml

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>

    <!-- 16 + 56 = 72 = "Content left margin from screen edge" -->
    <dimen name="content_horizontal_margin">56dp</dimen>
</resources>
Run Code Online (Sandbox Code Playgroud)

myactivity.xml

<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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin">

    <TextView
        android:id="@+id/tvEditPlaylistInfo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="@dimen/content_horizontal_margin"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="test" />

    <ImageButton
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:src="@drawable/action_current"
        android:layout_alignBottom="@id/tvEditPlaylistInfo"
        android:layout_toRightOf="@id/tvEditPlaylistInfo"
        android:layout_marginLeft="16dp"/>

    <ListView
        android:id="@+id/lvAudioFiles"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/content_horizontal_margin"
        android:layout_below="@id/tvEditPlaylistInfo">
    </ListView>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

但不知何故,我的内容被"关闭"大约8dp(模拟器,Lollipop 22).

在此输入图像描述

我正在使用父母的自定义主题,Theme.AppCompat.Light.DarkActionBar但我只改变颜色,所以我认为这不是我的问题的根源. …

android android-layout material-design

7
推荐指数
1
解决办法
2519
查看次数

标签 统计

android ×1

android-layout ×1

material-design ×1