-1
A
回答
0
要增加工具栏的高度:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/HEIGHT_THAT_YOU_WANT">
由于Toolbar
是任何你想要的开始和结束标记内的ViewGroup
你可以做。只是认为它是LinearLayout
。使用几个嵌套的布局来实现你想要的,最后用闭标签关闭它。
</android.support.v7.widget.Toolbar>
0
虽然它并不真正遵循材料设计,我推荐的东西。
试试这个伪代码
<Toolbar>
<LinearLayout orientation="horizontal">
<LinearLayout orientation="vertical">
<EditText/>
<LinearLayout orientation="horizontal">
<ImageView src="smallImage"/>
<ImageView src="smallImage"/>
<ImageView src="smallImage"/>
<ImageView src="smallImage"/>
</LinearLayout>
</LinearLayout>
<ImageView src="BigImage"/>
</LinearLayout>
</Toolbar>
然后,您需要设置宽度/高度,更好地服务于您的布局。
0
感谢所有提示!我终于做到了!我只是发布解决方案,以防万一有人需要它。所有的
1)首先,我创建在res /布局称为toolbar.xml一个文件,其中包含
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="?attr/colorPrimaryDark">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView5" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="@+id/textView6" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="@+id/textView7" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"`
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
或者
2)toolbar.xml添加到main_activity .xml,所以
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.tbr.qps3.MainActivity">
<include android:id="@+id/toolbar" layout="@layout/toolbar" />
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android">
...
</TableLayout>
</RelativeLayout>
3)现在只需膨胀在onCreate()我thod
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // Attaching the layout to the toolbar object
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
希望它有帮助!
相关问题
- 1. Android工具栏布局问题
- 2. 底部工具栏布局
- 3. Android - 无法修复折叠工具栏布局中的工具栏
- 4. 折叠工具栏中的工具栏布局不被固定
- 5. 使工具栏具有网格布局
- 6. 协调器布局中的工具栏
- 7. 工具栏和布局之间的layout_anchor
- 8. android布局设计工具
- 9. 崩溃的工具栏布局与Android中的2选项卡布局
- 10. 滚动工具栏不工作在Android使用框架布局
- 11. Android - 工具栏的子布局左侧的填充/空白键
- 12. Android的工具栏布局是水平的
- 13. 工具栏在布局中不可见
- 14. 坞工具栏底部垂直布局
- 15. 如何实现工具栏布局
- 16. 动态改变工具栏布局
- 17. Xamarin.Android CustomActionBar(工具栏)布局问题
- 18. JQuery UI工具栏按钮布局
- 19. 自定义工具栏布局对齐
- 20. 工具栏布局未定义
- 21. 如何保存工具栏布局?
- 22. Android:当前分段上的工具栏布局denpend
- 23. 如何在Android中的工具栏下启动抽屉布局?
- 24. 布局结构 - 卡片布局和工具栏与angularjs md
- 25. Android - 工具栏中的状态栏中的协调器布局中的片段
- 26. Android - 工具栏弹出式自定义布局
- 27. 折叠工具栏布局android标题ellipsizes
- 28. 将布局对齐到最左侧工具栏android
- 29. 工具栏和菜单栏的网格包布局
- 30. Android中的底栏布局
即使你想在“工具栏”中添加一个“工具栏”,并在里面添加“水平LinearLayout”。添加一个'Layout'和'ImageView'作为孩子,并给布局权重2和'ImageView'权重1 –
嗨,在检查下面的答案后,请告诉我问题是否仍然存在 – piotrek1543