是否可以为蓝色矩形中的选定区域设置所有状态的特定颜色。例如,Error 状态使 TextField 的所有组件变为红色,但是否可以使选定区域保持特定颜色而不改变?
主页
/
user-372622
izlom's questions
有一个成品。需要创建一个新的fragment,它与完成的fragment 不同之处仅在于它不包含editText,并且操作栏中的按钮具有稍微不同的逻辑。构建程序的最佳方法是什么?不要创建新片段并复制已完成片段的代码。
CardView (LinearLayout) 中有两个 MaterialButton。单击按钮时,不会选择将鼠标悬停在按钮上时设计器中显示的整个区域(该区域在图片中用红色矩形标记)。如何使当您单击按钮时,按钮上的整个区域被选中。只是当你点击按钮时,它们之间形成了某种形象,这是不应该的。
<androidx.constraintlayout.widget.ConstraintLayout
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:background="@color/colorBackgroundSetting"
tools:context=".Settings">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardPreventCornerOverlap="false"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
style="@style/SettingButtons"
android:text="@string/change_email">
</com.google.android.material.button.MaterialButton>
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<com.google.android.material.button.MaterialButton
style="@style/SettingButtons"
android:text="@string/change_password">
</com.google.android.material.button.MaterialButton>
</LinearLayout>
</androidx.cardview.widget.CardView>
<style name="SettingButtons" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:gravity">fill_vertical</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
<item name="android:textColor">@color/colorTextSetting</item>
<item name="android:textSize">@dimen/text_size</item>
<item name="android:textAllCaps">false</item>
<item name="icon">@drawable/ic_chevron_right_black_24dp</item>
<item name="iconTint">@color/colorTextSetting</item>
<item name="iconGravity">end</item>
</style>
有一些问题。学安卓有一段时间了。我需要在一个活动中实现三个片段(在它们之间显示/隐藏)。Fragment之间的过渡:我是通过接口来做的(我在Fragment中定义了接口,activity继承了这个接口并覆盖了,调用了通用的方法,增加了一个新的fragment,隐藏当前的或者显示的,一堆片段是相应创建的。)当我到达最后一个片段并单击后退按钮时,会过渡到前一个片段,但会显示所有先前隐藏的片段(第一个和第二个片段),但它们仍然存储在堆栈,当再次按下后退按钮时,第二个片段被隐藏。告诉我可能是什么问题?
private fun pushFragments(tag: String, fragment: Fragment) {
val manager = supportFragmentManager
val ft = manager.beginTransaction()
if (manager.findFragmentByTag(tag) == null) {
ft.add(R.id.container, fragment, tag)
}
val fragmentFirst = manager.findFragmentByTag(Const.TAG_ENTRANCE)
val fragmentSecond = manager.findFragmentByTag(Const.TAG_SIGN_IN)
val fragmentThird = manager.findFragmentByTag(Const.TAG_PERSONAL_DATA)
if (fragmentFirst != null) {
ft.hide(fragmentFirst)
}
if (fragmentSecond != null) {
ft.hide(fragmentSecond)
}
if (fragmentThird != null) {
ft.hide(fragmentThird)
}
if (tag === Const.TAG_ENTRANCE) {
if (fragmentFirst != null) {
ft.show(fragmentFirst)
}
}
if (tag === Const.TAG_SIGN_IN) {
if (fragmentSecond != null) {
ft.show(fragmentSecond)
}
}
if (tag === Const.TAG_PERSONAL_DATA) {
if (fragmentThird != null) {
ft.show(fragmentThird)
}
}
ft.addToBackStack(null).commit()
Log.d(TAG, "Количество в стеке:" + supportFragmentManager.backStackEntryCount)
}