在这里我正在创建登录屏幕,我必须在其中输入用户名和密码,在密码字段中我设置了眼睛图标。当输入密码时,密码将被隐藏,单击眼睛图标后,它应该显示真实的字符。我已经提到了我的 XML 和 java 代码。请查看并帮助我解决方案。我需要在 gradle 中添加任何内容吗?请建议。谢谢
<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:gravity="center_horizontal"
android:orientation="vertical"
tools:context="com.tecnotree.selfcare.ui.login.LoginActivity">
<VideoView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:visibility="gone"
android:id="@+id/background_video_view"
/>
<!-- Login progress -->
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/tecnotree_selfcare"
android:src="@drawable/login_background"
android:scaleType="centerCrop"/>
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:padding="@dimen/paddingLarge"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="@drawable/sc_card_rounded_login"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/marginLarge"
android:layout_marginBottom="@dimen/marginLarge"
android:contentDescription="@string/tecnotree_selfcare"
android:src="@drawable/logo" />
<TextView
style="@style/AppTheme.TextWhiteLargeBold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple, Secure …Run Code Online (Sandbox Code Playgroud) android android-edittext kotlin android-textinputlayout material-components
底部导航所选项目的颜色没有改变,尽管我提供了控制颜色变化的可绘制文件。我已经尝试了很多次,但我找不到代码中的错误。
请帮忙!
这是底部导航
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="@color/bottomBackground"
app:itemTextColor="@drawable/icon_color"
app:itemIconTint="@drawable/icon_color"
app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_navigation_menu"/>
Run Code Online (Sandbox Code Playgroud)
这是 icon_color
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorAccent" android:state_checked="true"/>
<item android:color="@color/grey" android:state_checked="false"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
编辑 :
当我删除这段代码时它工作正常
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
int id = menuItem.getItemId();
if(id == R.id.navigation_library) {
loadFragment(new LibraryFragment());
}
else if (id == R.id.navigation_for_you) {
loadFragment(new ForYouFragment());
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
为什么这段代码会干扰我的功能。
android android-layout android-xml bottomnavigationview material-components
我尝试设置标题颜色,但它已被弃用。我尝试使用来改变颜色
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如此处所述:ActionBar 文本颜色,但整个标题栏颜色在执行此操作时更改为白色。我想要做的就是将黑色标题栏文本颜色设置为白色。我也在这里尝试了这个解决方案:更改颜色标题栏,但我使用的是 MaterialComponents 主题,而使用 AppCompactThemes 会使我的应用程序崩溃。
java android android-actionbar material-components material-components-android
如何设计带圆角和透明关闭按钮的自定义警报对话框?
android android-alertdialog material-design material-components material-components-android
我正在使用圆形背景和圆形标签指示器设计 TabLayout。在下面的图片链接中,可以看到我的白色标签周围有某种填充。如何摆脱填充并完全填充选项卡?
我附上了我的选项卡布局的代码。我的背景和 tabIndicator 绘图是在草图中设计的 - 尺寸与下面的“预期结果”完全相同。
<com.google.android.material.tabs.TabLayout
android:id="@+id/newgroup_tabs"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_marginTop="22dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/newgroup_tabbg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvnewgroups_title"
app:tabGravity="fill"
app:tabInlineLabel="true"
app:tabIndicator="@drawable/newgroup_tabindicatorwide"
app:tabIndicatorColor="@color/white"
app:tabIndicatorFullWidth="true"
app:tabIndicatorGravity="center"
app:tabIndicatorHeight="54dp"
app:tabMode="fixed"
app:tabTextColor="@color/black" />
Run Code Online (Sandbox Code Playgroud)
我的预期结果应该是这样的,https://ibb.co/XYZ2jkS
但我实际得到的是这个,https://ibb.co/Lz1C0Fy。
如何让我的设计看起来像预期的图像?任何帮助将不胜感激,谢谢!
android android-layout android-tablayout material-components material-components-android
我正在尝试设置按钮样式,使其没有边框半径。我曾尝试将该radius属性设置为0sp,但这不起作用。下面是我的代码和结果按钮的屏幕截图,它仍然有圆角。
<com.google.android.material.button.MaterialButton
android:id="@+id/material_text_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:textAppearance="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_marginTop="11sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:radius="0sp"
android:text="#1 Lorem Ipsum"
android:textSize="16sp"/>
Run Code Online (Sandbox Code Playgroud)
android android-button android-studio material-components material-components-android