按钮在android.support.v7.widget.Toolbar上不可见
我在按钮在android.support.v7.widget.Toolbar上不可见,android,xml,Android,Xml,我在工具栏前面放置了一个按钮,但问题是,用户看不到它。 我希望我的按钮在工具栏中可见,或者它应该放在工具栏上 这是我的密码 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="
工具栏
前面放置了一个按钮
,但问题是,用户看不到它。
我希望我的按钮在工具栏中可见,或者它应该放在工具栏上
这是我的密码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.Intro">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center"
android:src="@drawable/ione" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/holo_blue_dark"
android:elevation="16dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="16dp"
android:text="Button" />
按钮在android.support.v7.widget.Toolbar上不可见
将按钮放在工具栏布局内
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/holo_blue_dark"
android:elevation="16dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="16dp"
android:text="Button" />
</android.support.v7.widget.Toolbar>
- 也可以通过menu.xml使用菜单项在工具栏内创建按钮
按钮在android.support.v7.widget.Toolbar上不可见
将按钮放在工具栏布局内
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/holo_blue_dark"
android:elevation="16dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="16dp"
android:text="Button" />
</android.support.v7.widget.Toolbar>
- 也可以通过menu.xml使用菜单项在工具栏内创建按钮
简单地说,为工具栏上方的按钮编写xml标记
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.Intro">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center"
android:src="@drawable/ione" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="16dp"
android:text="Button" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/holo_blue_dark"
android:elevation="16dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />
简单地说,为工具栏上方的按钮编写xml标记
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.Intro">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center"
android:src="@drawable/ione" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="16dp"
android:text="Button" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/holo_blue_dark"
android:elevation="16dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />
如果你想把它放在工具栏上,为什么不把它放在工具栏上,而不是放在工具栏外面?用一个菜单项代替为什么你的工具栏在底部?这就是你所需要的吗?因为我正在创建一个应用程序。如果你想把它放在工具栏上,为什么不把它放在工具栏上而不是它的外部呢?使用一个菜单项而不是为什么你的工具栏在底部?这就是你需要的吗?因为我正在创建一个应用程序介绍