使用时是否可以AppCompatActivity指定getSupportActionBar().setDisplayHomeAsUpEnabled(true)使用样式,而不是以编程方式这样做?
我可以指定可绘制对象本身,但如何使用样式启用它?
<style name="MyActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarTheme">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="homeAsUpIndicator">@drawable/ic_clear</item>
<!-- Enable the above using a style attribute -->
</style>
Run Code Online (Sandbox Code Playgroud) 我正在使用线性布局的高程属性,但阴影太亮。我只需要一个较暗的阴影用于线性布局。
我添加android:spotShadowAlpha到我的styles.xml. 它有效,但不仅仅适用于线性布局。每个视图都有一个较暗的阴影。
样式.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:ambientShadowAlpha">0</item>
<item name="android:spotShadowAlpha">0.55 </item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
线性布局在activity_main.xml
<LinearLayout
android:id="@+id/linl"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_marginStart="55dp"
android:layout_marginTop="208dp"
android:layout_marginEnd="56dp"
android:layout_marginBottom="209dp"
android:background="@drawable/custom_buttom"
android:elevation="70dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
背景@drawable/custom_buttom
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners android:radius="999dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud) 在我的页面中包含很多layouts,我想为每个画一个角落,layout所以我尝试:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff"/>
<corners android:radius="5px"/>
<stroke android:width="2dip" android:color="#ababab"/>
<padding android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
所以颜色shape是白色但我想要的只是一个border并使用background默认值.
怎么设置呢?
我有一个EditText在TextInputLayout.
<android.support.design.widget.TextInputLayout
android:id="@+id/inputTextUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout" >
<EditText
android:id="@+id/userName"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ems="10"
android:hint="@string/user_hint"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="16sp" >
<requestFocus />
</EditText>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我希望将底线颜色更改为白色,我尝试了这个解决方案,但它不能与我合作:
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorHint">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
<item name="colorControlHighlight">@color/white</item>
</style>
<style name="TextAppearence.App.TextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/light_blue_A400</item>
<item name="android:textSize">12sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是风格主题后的图像:
有什么建议可以在不聚焦和聚焦时改变颜色底线?
android android-edittext android-styles android-design-library
我尝试将动作模式图标颜色设置为白色(复制,粘贴,共享等等).我正在使用AppCompat支持.我知道我可以用这个:
<style name="Widget.ActionMode">
<item name="actionModeCutDrawable">@drawable/abc_ic_menu_cut_mtrl_alpha</item>
<item name="actionModeCopyDrawable">@drawable/abc_ic_menu_copy_mtrl_am_alpha</item>
<item name="actionModePasteDrawable">@drawable/abc_ic_menu_paste_mtrl_am_alpha</item>
<item name="actionModeSelectAllDrawable">@drawable/abc_ic_menu_selectall_mtrl_alpha</item>
<item name="actionModeShareDrawable">@drawable/abc_ic_menu_share_mtrl_alpha</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但我不想设置图像drawables,只是为了设置颜色.我认为android采用主题的图标颜色,但我不能通过这种方式改变它,所以也许不是?
我想了解,之间有什么区别Toolbar,Appbar,ActionBar.而我正试图改变我的AppBar或其他任何颜色的红色.
有人提到尝试改变主题.我试过但不知道差异,我也是android编程的新手.所以,如果你能帮助我.这是styles.xml文件代码
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"
>
<item name="android:titleTextStyle">@style/MyTextTitle</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" >
<item name="android:titleTextStyle">@style/MyTextTitle</item>
</style>
<style name="MyTextTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我希望你明白我想说的话.原谅我的无知,因为我渴望学习它,所以不能等待.
如何更改操作栏切换按钮的颜色?
这是我的Java操作栏代码:
//Navigation view and Drawer layout
drawerlayout = (DrawerLayout) findViewById(R.id.main_ND);
actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerlayout,0,0);
navigationView = (NavigationView) findViewById(R.id.main_NV);
navigationView.setItemIconTintList(null);
View headerView = navigationView.getHeaderView(0);
nD_image = (ImageView) headerView.findViewById(R.id.nd_image);
Glide.with(getBaseContext()).load(R.drawable.my_paper).centerCrop().into(nD_image);
setNavigationView();
drawerlayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if(actionBarDrawerToggle.onOptionsItemSelected(item))
{
return true;
}
return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)
以我的风格
<style name="my_theme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/salmonDark</item>
<item name="colorPrimary">@color/salmon_main</item>
<item name="colorAccent">@color/black</item>
<item name="android:actionMenuTextColor">@color/white</item><!-- green was: #8BC34A -->
<item name="android:actionMenuTextAppearance">@style/actionBarTextSize</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后在我的清单上
<activity android:name=".Main.Main"
android:screenOrientation="portrait"
android:theme="@style/zivit_theme"/>
Run Code Online (Sandbox Code Playgroud)
我不太确定如何更改颜色或在哪里进行更改。我希望有人可以张贴一些分步过程的示例代码(或执行此操作的那神奇的一行代码),谢谢!
android android-layout android-xml android-actionbar android-styles
我正在使用日期选择器,我需要用不同的颜色设置样式。除了选定的日期颜色,所有其他东西都工作正常。选择的日期颜色默认为“ android:textColorPrimaryInverse”,在我的情况下为红色,对话框背景为白色,“ android:colorControlHighlight”和“ android:colorControlActivated”也为红色。
这意味着所选的文本颜色不会显示。我需要将其显示为白色,但是问题是如果我将“ android:textColorPrimaryInverse”更改为白色,则背景为白色时我的标题将不会显示。
这是我的样式文件:
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/color_white</item>
<item name="android:textColorPrimaryInverse">@color/red</item>
<item name="android:textColorSecondaryInverse">@color/red</item>
<item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
<item name="buttonBarButtonStyle">@style/DialogButtonStyle</item>
<item name="android:colorControlHighlight">@color/red</item>
<item name="android:colorControlActivated">@color/red</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这就是我显示对话框的方式
new DatePickerDialog(mActivity, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
//DO SOMETHING
}
}, 2015, 02, 26).show();
Run Code Online (Sandbox Code Playgroud) 编辑: 我想摆脱的栏是顶部的栏,上面写着测试。我要更改的文本颜色是用户输入的“testing@gmail.com”文本:
这是我的登录活动的 XML(我使用了 android studio 提供的默认登录活动):
<LinearLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.uname.myapp.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"
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="match_parent">
<LinearLayout
android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="6"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_sign_in"
android:textStyle="bold" />
</LinearLayout>
</ScrollView> …Run Code Online (Sandbox Code Playgroud) android android-layout android-studio android-styles android-studio-3.0