【问题标题】:Android title bar custom view does not stretchAndroid标题栏自定义视图不拉伸
【发布时间】:2014-10-24 14:13:18
【问题描述】:

我在我的应用程序中使用 api 21 标题栏。我想在其上拉伸我的按钮或 Linearlayout,但我不能。 我的代码:

<LinearLayout 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:orientation="vertical"
tools:context="com.example.toolbartest.MainActivity" >
<android.support.v7.widget.Toolbar  
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#ff9900"> 
<Button
    android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="GSSGSDGSDG"/>
</android.support.v7.widget.Toolbar>

</LinearLayout>![enter image description here][1]


Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

我知道了:

【问题讨论】:

  • 可能有助于在开发人员设置中打开“显示布局边界”。

标签: android android-actionbar titlebar


【解决方案1】:

我解决了,这里是xml代码:

<android.support.v7.widget.Toolbar
    xmlns:plugshare="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/my_awesome_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#ff9900"
    android:minHeight="?attr/actionBarSize"
    app1:contentInsetStart="0dp" >

 <Button
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:text="GGSSSDFSDFSFFSDF" /> 
</android.support.v7.widget.Toolbar>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多