Android Layout XML属性研究--android:layout_marginBottom (转载)

本文详细阐述了在XML配置文件中,如何通过调整RelativeLayout和ImageButton的属性来解决ImageButton与RelativeLayout底边的间距问题。通过实例演示,展示了如何利用android:layout_alignParentBottom和android:layout_marginBottom属性实现目标布局效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://blog.youkuaiyun.com/yanfangjin/article/details/7393023

 

在如下的xml配置文件中,起初对于android:layout_marginBottom,即需要控制imagebutton对于向下的间距,则不能working。

 

<RelativeLayout
        android:id="@+id/bar"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:background="@drawable/ic_bar_bg"
        android:layout_alignParentRight="true"
        android:orientation="horizontal" >

<ImageButton
            android:id="@+id/gallery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10dp"
            android:background="@drawable/ic_frame"/> 

</RelativeLayout>

 

查看很多的blog,对于releated layout的设置有一定的了解,后续测试中,添加了如下的设置android:layout_alignParentBottom="true",则能够使用layout_marginBottom这个特性,因此认为默认的设置,alignParantBottom肯定是false,因此layout_marginBottom不起作用。

<RelativeLayout
        android:id="@+id/bar"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:background="@drawable/ic_bar_bg"
        android:layout_alignParentRight="true"
        android:orientation="horizontal" >

<ImageButton
            android:id="@+id/gallery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="10dp"
            android:background="@drawable/ic_frame"/> 

</RelativeLayout>

转载于:https://www.cnblogs.com/lance-ehf/p/4380050.html

shu3.xml:<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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" android:background="@drawable/gradient_background" tools:context=".ShuHai3Activity"> <!-- Toolbar --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <Button android:id="@+id/back_button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:background="@android:color/transparent" android:contentDescription="返回上一页" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="19dp" /> </RelativeLayout> <!-- 播放视频区域 --> <!-- 时间线和缩略图区域 --> <FrameLayout android:id="@+id/video_container" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintHeight_percent="0.55" android:background="@android:color/black" app:layout_constraintBottom_toTopOf="@id/thumbnail_scrollview" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.6" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/toolbar" app:layout_constraintVertical_bias="0.0"> <!-- 模拟萤石播放加载动画 --> <ProgressBar android:id="@+id/video_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <!-- 视频播放View,可以替换成具体的视频播放控件 --> <VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="视频播放区域" android:textColor="@android:color/white" android:visibility="visible" /> </FrameLayout> <ScrollView android:id="@+id/thumbnail_scrollview" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintHeight_percent="0.45" android:fillViewport="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/video_container"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.GridLayout android:id="@+id/gridLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:columnCount="2" app:rowCount="0" app:alignmentMode="alignBounds" app:useDefaultMargins="true" android:padding="8dp"> <!-- 多个缩略图子项 --> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> </android.support.v7.widget.GridLayout> </LinearLayout> </ScrollView> </android.support.constraint.ConstraintLayout> 修改下面shuhaisp.xml布局和上面shu3.xml布局一样,保持shuhaisp.xml依赖不变必须使用android支持库。shuhaisp.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" android:background="@drawable/gradient_background"> <!-- tools:context=".ShuhaiSp"--> <!-- <!– 顶部工具栏 –>--> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#44bd32"> <Button android:id="@+id/back_button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:background="@android:color/transparent" android:contentDescription="返回上一页" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="19dp" /> </RelativeLayout> <!-- 视频播放区域 --> <FrameLayout android:id="@+id/video_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@id/toolbar" android:layout_above="@+id/thumbnail_scrollview" android:layout_marginTop="0dp" android:background="@android:color/black"> <ProgressBar android:id="@+id/video_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="视频播放区域" android:textColor="@android:color/white" android:visibility="visible" /> </FrameLayout> <!-- 缩略图区域 --> <ScrollView android:id="@+id/thumbnail_scrollview" android:layout_width="match_parent" android:layout_height="0dp" android:layout_alignParentBottom="true" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.widget.GridLayout android:id="@+id/gridLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="2" android:rowCount="0" android:alignmentMode="alignBounds" android:useDefaultMargins="true" android:padding="8dp"> <!-- 缩略图示例 --> <!-- <ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_columnWeight="1" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="缩略图" android:src="@drawable/default_thumbnail" /> --> </android.widget.GridLayout> </LinearLayout> </ScrollView> </RelativeLayout>
06-25
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_background"> <!-- 标题栏 --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:background="#44bd32"> <Button android:id="@+id/fanHui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:background="@android:color/transparent" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="16sp" /> </RelativeLayout> <!-- 底部按钮 --> <LinearLayout android:id="@+id/footer_buttons" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignParentBottom="true" android:background="@android:color/white" android:orientation="horizontal"> <!-- <Button--> <!-- android:id="@+id/device_location"--> <!-- android:layout_width="match_parent"--> <!-- android:layout_height="match_parent"--> <!-- android:gravity="center"--> <!-- android:text="设备定位"--> <!-- android:textSize="19sp"--> <!-- android:background="#44bd32"--> <!-- android:textColor="@android:color/white" />--> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="380dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/toolbar" android:layout_marginBottom="298dp" android:background="@android:color/black" android:padding="0dp"> <!-- 视频播放器 --> <VideoView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" /> <!-- 播放控制条 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#99000000" android:orientation="horizontal" android:padding="8dp"> <ImageButton android:id="@+id/btn_play_pause" android:layout_width="40dp" android:layout_height="40dp" android:background="?attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_play_sel" /> <SeekBar android:id="@+id/video_seekbar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="00:00/00:00" android:textColor="@android:color/white" android:textSize="14sp" /> </LinearLayout> </RelativeLayout> <GridLayout android:id="@+id/thumbnail_grid" android:layout_width="match_parent" android:layout_height="301dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/video_container" android:layout_marginBottom="-1dp" android:background="@android:color/white" android:columnCount="4" android:padding="8dp" android:rowCount="2"> <!-- 动态添加的缩略图将放在这里 --> <!-- 示例缩略图 (可选) --> <ImageView app:layout_columnWeight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" /> <!-- 更多缩略图... --> </GridLayout> </RelativeLayout> 依据上述代码解决2个报错:Cannot resolve symbol '@id/video_container' Namespace 'app' is not bound
06-27
要求参考已有的activity_add_task.xml内容如下,并给出完整的activity_edit_task.xml:<?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView 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" android:background="@color/light_background" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <!-- 标题栏 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:paddingBottom="16dp" android:text="创建新任务" android:textColor="@color/primary_dark" android:textSize="24sp" android:textStyle="bold" /> <!-- 必填项卡片 --> <com.google.android.material.card.MaterialCardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:cardCornerRadius="12dp" app:cardElevation="4dp" app:strokeColor="@color/primary_light" app:strokeWidth="1dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <!-- 卡片标题 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_info_outline" android:drawablePadding="8dp" android:gravity="center_vertical" android:paddingBottom="12dp" android:text="必填信息" android:textColor="@color/primary_dark" android:textSize="18sp" android:textStyle="bold" /> <!-- 任务标题 --> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="任务标题 *" app:boxStrokeColor="@color/primary" app:errorEnabled="true"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/taskTitleEditText" style="@style/CustomTextInputEditText" android:layout_width="match_parent" android:layout_height="wrap_content" /> </com.google.android.material.textfield.TextInputLayout> <!-- 分类选择 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="分类 *" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <!-- 分类按钮组 - 紧凑布局 --> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/categoryToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 重要性行 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="重要性 *" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:gravity="center_vertical" android:orientation="horizontal" android:paddingVertical="10dp"> <RatingBar android:id="@+id/importanceRatingBar" style="@style/Widget.AppCompat.RatingBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:isIndicator="false" android:numStars="5" android:progressBackgroundTint="@color/light_gray" android:progressTint="@color/primary" android:rating="3" android:stepSize="1" android:theme="@style/RatingBarStyle" /> <TextView android:id="@+id/ratingText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:text="中等" android:textColor="@color/primary_dark" android:textSize="16sp" /> </LinearLayout> <!-- 期待完成时长 - 标签和设置在同一行 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:text="期待完成时长 *" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <TextView android:id="@+id/durationDisplay" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0 分钟" android:textColor="@color/red" android:textSize="14sp" /> </LinearLayout> <!-- 时间增加按钮行 - 完全按照原界面设计 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="4dp" android:orientation="horizontal"> <TextView android:id="@+id/add60TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+60" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add30TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+30" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add15TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+15" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add10TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+10" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add5TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+5" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add1TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+1" android:textColor="@color/primary_dark" android:textSize="14sp" /> </LinearLayout> <!-- 时间减少按钮行 - 完全按照原界面设计 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/reduce60TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-60" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce30TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-30" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce15TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-15" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce10TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-10" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce5TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-5" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce1TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-1" android:textColor="@color/primary_dark" android:textSize="14sp" /> </LinearLayout> </LinearLayout> </com.google.android.material.card.MaterialCardView> <!-- 子任务卡片 - 新增独立卡片 --> <com.google.android.material.card.MaterialCardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:cardCornerRadius="12dp" app:cardElevation="4dp" app:strokeColor="@color/primary_light" app:strokeWidth="1dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <!-- 子任务标题 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_subtask" android:drawablePadding="8dp" android:gravity="center_vertical" android:paddingBottom="12dp" android:text="子任务" android:textColor="@color/primary_dark" android:textSize="18sp" android:textStyle="bold" /> <!-- 添加子任务按钮 --> <com.google.android.material.button.MaterialButton android:id="@+id/addSubtaskButton" style="@style/Widget.MaterialComponents.Button.OutlinedButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:drawableStart="@drawable/ic_add_24dp" android:drawableTint="@color/primary" android:text="添加子任务" android:textColor="@color/primary" app:iconGravity="textStart" /> <!-- 子任务列表 --> <LinearLayout android:id="@+id/subtasksContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="2dp"> <!-- 空状态提示 --> <TextView android:id="@+id/emptySubtasksText" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="24dp" android:text="暂无子任务,点击上方按钮添加" android:textColor="#888" /> </LinearLayout> </LinearLayout> </com.google.android.material.card.MaterialCardView> <!-- 可选项折叠面板 --> <com.google.android.material.card.MaterialCardView android:id="@+id/expandableCard" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:cardCornerRadius="12dp" app:cardElevation="2dp"> <!-- 折叠面板标题 --> <LinearLayout android:id="@+id/expandableHeader" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:minHeight="56dp" android:orientation="horizontal" android:padding="16dp"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:drawableStart="@drawable/ic_baseline_tune_24" android:drawablePadding="8dp" android:gravity="center_vertical" android:text="更多选项" android:textColor="@color/primary" android:textSize="16sp" android:textStyle="bold" /> <ImageView android:id="@+id/expandIcon" android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="center" android:src="@drawable/ic_baseline_expand_more_24" app:tint="@color/primary" /> </LinearLayout> <!-- 可选项内容(默认折叠) --> <LinearLayout android:id="@+id/expandableContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="40dp" android:orientation="vertical" android:padding="16dp" android:visibility="gone"> <!-- 任务执行日期 - 移动到更多选项中 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="任务执行日期" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <!-- 日期选项组 - 减少间距确保文本完整显示 --> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/dateToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> <com.google.android.material.button.MaterialButton android:id="@+id/btnToday" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="今天" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnTomorrow" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="明天" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnSelectDate" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="选择日期" app:backgroundTint="@color/button_background_selector" /> <!-- 确保"没有日期"完全显示 --> <com.google.android.material.button.MaterialButton android:id="@+id/btnNoDate" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.2" android:text="没有日期" app:backgroundTint="@color/button_background_selector" /> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 父级目标 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="父级目标" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="选择父级目标" app:boxStrokeColor="@color/primary_light" app:hintTextColor="@color/gray_500" app:startIconTint="@color/primary"> <com.google.android.material.textfield.MaterialAutoCompleteTextView android:id="@+id/parentTargetAutoComplete" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="none" android:padding="3dp" android:paddingLeft="8dp" /> </com.google.android.material.textfield.TextInputLayout> <!-- 重复选项 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="重复选项" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <!-- 重复选项组 - 增加"每年"选项并调整间距 --> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/repeatToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> <com.google.android.material.button.MaterialButton android:id="@+id/btnNoRepeat" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="不重复" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnDaily" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="每日" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnWeekly" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="每周" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnMonthly" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="每月" app:backgroundTint="@color/button_background_selector" /> <!-- 新增每年选项 --> <com.google.android.material.button.MaterialButton android:id="@+id/btnYearly" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="每年" app:backgroundTint="@color/button_background_selector" /> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 任务描述 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="任务描述" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="详细描述任务内容..." app:boxStrokeColor="@color/primary_light" app:startIconDrawable="@drawable/ic_baseline_description_24" app:startIconTint="@color/primary"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/taskDescriptionEditText" style="@style/CustomTextInputEditText" android:layout_width="match_parent" android:layout_height="120dp" android:gravity="top" android:inputType="textMultiLine" /> </com.google.android.material.textfield.TextInputLayout> <!-- 提醒设置 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="提醒设置" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:orientation="vertical"> <androidx.appcompat.widget.SwitchCompat android:id="@+id/reminderSwitch" android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="false" android:text="启用提醒" android:textColor="@color/gray_500" /> <LinearLayout android:id="@+id/reminderOptionsLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal" android:visibility="gone"> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_weight="1" android:hint="提前时间" app:boxStrokeColor="@color/primary_light"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/reminderTimeEditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number" /> </com.google.android.material.textfield.TextInputLayout> <Spinner android:id="@+id/reminderUnitSpinner" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> </LinearLayout> <!-- 任务状态 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="任务状态" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/statusToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> <com.google.android.material.button.MaterialButton android:id="@+id/btnNotStarted" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="未开始" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnInProgress" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="进行中" app:backgroundTint="@color/button_background_selector" /> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 进度设置 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="进度 (%)" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:gravity="center_vertical" android:orientation="horizontal"> <SeekBar android:id="@+id/progressSeekBar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:max="100" android:progress="0" /> <TextView android:id="@+id/progressText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:text="0%" android:textColor="@color/primary_dark" android:textSize="16sp" /> </LinearLayout> <!-- 创建时机选择 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="创建时机" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:boxStrokeColor="@color/primary" app:startIconDrawable="@drawable/ic_baseline_access_time_24" app:startIconTint="@color/primary"> <com.google.android.material.textfield.MaterialAutoCompleteTextView android:id="@+id/creationTimingSpinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="false" android:hint="选择创建时机" android:inputType="none" /> </com.google.android.material.textfield.TextInputLayout> </LinearLayout> </com.google.android.material.card.MaterialCardView> <!-- 操作按钮 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="horizontal" android:paddingTop="8dp"> <com.google.android.material.button.MaterialButton android:id="@+id/cancelButton" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_weight="1" android:text="取消" android:textColor="@color/primary_dark" app:backgroundTint="@color/light_gray" /> <com.google.android.material.button.MaterialButton android:id="@+id/createButton" style="@style/Widget.MaterialComponents.Button" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_weight="1" android:text="创建任务" android:textColor="@color/white" app:backgroundTint="@color/primary" /> </LinearLayout> </LinearLayout> </androidx.core.widget.NestedScrollView>
最新发布
07-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值