Jia*_*Tse 8 toolbar android-appcompat material
我正在使用支持v7的工具栏.我添加了一个自定义视图,但自定义视图似乎不遵守"match_parent".它只会伸展到它看到的第一个图标.有谁知道解决这个问题?或者工具栏不是以这种方式使用的?

我的代码:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context="com.example.activities.ToolbarActivity"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="100dp"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/light_gray"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:gravity="bottom"
android:clipChildren="false"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/green"
>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
小智 1
我通过西蒙的链接中的方法取得了成功:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context="com.example.activities.ToolbarActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="100dp"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/light_gray"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="70dp"
android:background="@color/green">
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2537 次 |
| 最近记录: |