gpt4 book ai didi

android - 如何将按钮放在 android.support.design.widget.AppBarLayout 之上?

转载 作者:行者123 更新时间:2023-11-30 00:56:58 24 4
gpt4 key购买 nike

我有一个位于 android.support.design.widget.AppBarLayout 之上的按钮但按钮在布局显示和设备上留在它后面我如何将按钮放在它前面?

或者在另一个问题中,我如何在右上角的屏幕选项菜单旁边添加一个按钮?

这是我的布局 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:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="apps.radwin.wintouch.activities.alignmentActivities.WorkordersSelectionActivity"
tools:showIn="@layout/app_bar_workorders_selection">

<Button
android:id="@+id/filterButtonMainWorkorderSelection"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="50dp"

android:layout_marginTop="20dp"
android:background="@drawable/ic_filter_list_black_24dp"
android:text=""
android:textSize="30dp" />



<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">

</android.support.v7.widget.Toolbar>

<android.support.design.widget.TabLayout
android:id="@+id/tabsLayoutWorkorderSelection"
android:layout_width="match_parent"
style="@style/TabLayoutStyle"
android:layout_height="wrap_content"
/>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/workorderSelectionMainViewPagerContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@drawable/add_workorders_plus"
android:layout_marginLeft="@dimen/fab_margin"
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginBottom="@dimen/fab_margin"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />



<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:background="#293339"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/fab">


<TextView
android:id="@+id/workorderFilterPopup_showAllText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:gravity="center"
android:paddingTop="5dp"
android:text="SHOW ALL"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="20dp" />

<Button
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:id="@+id/filter_menu_workorders_show_all"
android:background="@color/transparent"
android:layout_marginLeft="10dp"
android:paddingTop="5dp"
/>

<ImageView
android:id="@+id/workorderFilterPopup_showAllCheckMark"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_done_black_24dp" />

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:id="@+id/workorderFilterPopup_showAllTextLine"
android:background="@color/white"
android:layout_below="@+id/workorderFilterPopup_showAllText"
></View>

<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/ic_alarm_black_24dp"
android:id="@+id/workorderFilterPopup_plannedImage"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/workorderFilterPopup_showAllTextLine"
android:layout_alignParentStart="true" />

<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:id="@+id/filter_menu_workorders_planned"
android:background="@color/transparent"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/workorderFilterPopup_showAllTextLine"
android:layout_alignParentStart="true"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Planned"
android:textColor="@color/white"
android:layout_marginLeft="20dp"
android:id="@+id/workorderFilterPopup_plannedText"
android:layout_alignBottom="@+id/workorderFilterPopup_plannedImage"
android:layout_toEndOf="@+id/workorderFilterPopup_plannedImage" />

<ImageView
android:id="@+id/workorderFilterPopup_PlannedCheckMark"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="20dp"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/workorderFilterPopup_plannedText"
android:src="@drawable/ic_done_black_24dp" />

<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/ic_cloud_off_black_24dp"
android:id="@+id/workorderFilterPopup_incompleteImage"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/workorderFilterPopup_plannedImage"
android:layout_alignParentStart="true" />

<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:id="@+id/filter_menu_workorders_incomplete"
android:background="@color/transparent"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/workorderFilterPopup_plannedImage"
android:layout_alignParentStart="true"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Uncompleted"
android:textColor="@color/white"
android:layout_marginLeft="20dp"
android:id="@+id/workorderFilterPopup_intompleteText"
android:layout_alignBottom="@+id/workorderFilterPopup_incompleteImage"
android:layout_toEndOf="@+id/workorderFilterPopup_incompleteImage" />

<ImageView
android:id="@+id/workorderFilterPopup_IncompleteCheckMark"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="20dp"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/workorderFilterPopup_intompleteText"
android:src="@drawable/ic_done_black_24dp" />

<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/ic_cloud_queue_black_24dp"
android:id="@+id/workorderFilterPopup_CompleteImage"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/workorderFilterPopup_incompleteImage"
android:layout_alignParentStart="true" />

<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:id="@+id/filter_menu_workorders_complete"
android:background="@color/transparent"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/workorderFilterPopup_incompleteImage"
android:layout_alignParentStart="true"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="complete 5"
android:textColor="@color/white"
android:layout_marginLeft="20dp"
android:id="@+id/workorderFilterPopup_completeText"
android:layout_alignBottom="@+id/workorderFilterPopup_CompleteImage"
android:layout_toEndOf="@+id/workorderFilterPopup_CompleteImage" />

<ImageView
android:id="@+id/workorderFilterPopup_completeCheckMark"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="20dp"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/workorderFilterPopup_completeText"
android:src="@drawable/ic_done_black_24dp" />



<View
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_below="@+id/workorderFilterPopup_CompleteImage"
></View>


</RelativeLayout>



</android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>




</RelativeLayout>

最佳答案

将您的按钮包裹在卡片 View 中,并为卡片 View 提供一些高度。我尝试了以下代码:(使用 Textview 而不是 Button)

<androidx.cardview.widget.CardView
android:id="@+id/filterButtonMainWorkorderSelection"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="50dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardElevation="6dp"
android:layout_marginTop="20dp">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_flash_auto_black_24dp"
android:textSize="30dp" />

</androidx.cardview.widget.CardView>

关于android - 如何将按钮放在 android.support.design.widget.AppBarLayout 之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39973062/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com