将其从您的TextView
and ListView
:
android:layout_marginLeft="@dimen/content_horizontal_margin"
您的父标签已经指定了填充应该是什么:
<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">
之所以关闭是因为你正在填充,然后设置边距。
另外,只是为了兴趣,这里是内边距和边距的区别 https://stackoverflow.com/a/25520320/4180965.
UPDATE
根据与 @0X0nosugar 的讨论,我们已经得出以下代码有助于实现您的目标:
为了更改 ActionBar,应将以下内容添加到 onCreate() 中:
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
{
View customView = getLayoutInflater().inflate(R.layout.custom_action_bar, null);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(customView);
}
为工具栏创建自定义视图
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/accent_deeporangeA400"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MyMusicApp"
android:id="@+id/ab_title"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</RelativeLayout>
这应该可以帮助您实现目标!你的研究很好!