小编Yog*_*ogi的帖子

工具栏的左侧增加了额外的空间

我在应用程序中使用了自定义工具栏。工具栏的左侧增加了额外的空间。这是我的Xml文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/customActionBar"
    android:layout_height="wrap_content"
    android:background="@color/titleBar">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:id="@+id/leftIcon"
        android:src="@drawable/abc_btn_rating_star_on_mtrl_alpha"
        android:background="@android:color/transparent"
        android:layout_weight="0.2"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/actionTitleText"
        android:text="@string/app_name"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:textSize="@dimen/text_22sp"
        android:padding="@dimen/size_12dip"
        android:gravity="center_horizontal"
        android:layout_weight="0.6"/>

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/rightIcon"
        android:src="@drawable/abc_btn_rating_star_on_mtrl_alpha"
        android:background="@android:color/transparent"
        android:layout_weight="0.2"/>
</LinearLayout>


</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

你能帮忙吗?它从屏幕的左边给出了一些边距,但是我没有给出任何边距属性。这是将其膨胀为活动的代码:

 @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        super.setContentView(R.layout.activity_main);
        baseViewContent = (LinearLayout) findViewById(R.id.main_activity_content_view);
        viewController = new ViewController(this, baseViewContent);
        activity = this;

        // Set a toolbar to replace the action bar.
        android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.customActionBar);
        setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud)

android android-toolbar

2
推荐指数
1
解决办法
1208
查看次数

标签 统计

android ×1

android-toolbar ×1