我目前在使用Holo.Light主题的自定义ListView适配器时遇到问题.在活动和片段中,任何TextView都显示在主题的常规颜色(textColorPrimary)中.但是,自定义ListAdapter中的任何文本都使用textColorPrimary默认的Holo主题,从而有效地使文本不可读.
以下是我应用主菜单中的示例:
list_main_menu.xml - ListAdapter的行布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgIcon"
android:layout_height="48dip"
android:layout_width="48dip"
android:src="@drawable/ic_launcher"
/>
<TextView
android:id="@+id/txtFirstLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/imgIcon"
android:text="Line 1"
android:textSize="12pt"
/>
<TextView
android:id="@+id/txtSecondLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/imgIcon"
android:layout_below="@id/txtFirstLine"
android:text="Line 2"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
注意:我目前不得不android:textColor="?android:attr/textColorPrimaryInverse"用来使文本可读.
fragment_main_menu.xml - 主菜单片段.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtWelcome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Username"
android:textSize="18sp"
/>
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
AndroidManifext.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.michaeldodd.treasurehunter" …Run Code Online (Sandbox Code Playgroud) 我有一个平板电脑应用程序,我正在进行品牌重塑,因此有多个主题,基于用户的类型.
我想找到当前正在应用的主题的名称,然后基于该主题,我可以进行一些后端功能更改.
我必须动态设置一些图像资源,只要我传入正确的主题资源(R.style.redtheme)就可以了,但我想动态设置它.
TypedArray a = getTheme().obtainStyledAttributes(R.style.redtheme, new int[] {aTabResource.mDrawableAttrId});
Run Code Online (Sandbox Code Playgroud)
为了做样式我正在创建自定义属性,然后在样式中覆盖它们.
如果没有简单的方法来获得主题,我将保存一个偏好.
我有一个带有操作栏的应用程序,如下所示:

我希望菜单操作按钮"Home"和"Logout"的文本也是白色的.如何更改文字颜色?
如果您想查看任何代码,请告诉我们.
谢谢!
android android-theme android-4.0-ice-cream-sandwich actionbarsherlock android-actionbar
有人能告诉我如何消除应用徽标左侧的填充???
这就是我在谈论的http://s9.postimage.org/ksxjpx1e7/Untitled.png
即使使用ABS演示,您也可以通过添加来轻松地重现这一点 AndroidManifest.xml
android:logo="@drawable/icon"
我甚至尝试abs__action_bar_home.xml直接编辑,但不知何故该死的填充仍然存在.
<view xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
class="com.actionbarsherlock.internal.widget.ActionBarView$HomeView"
android:background="#00ff00" >
<ImageView
android:id="@id/abs__home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:padding="0dip"
android:layout_marginLeft="0dip"
android:layout_marginBottom="@dimen/abs__action_bar_icon_vertical_padding"
android:layout_marginRight="8dip"
android:layout_marginTop="@dimen/abs__action_bar_icon_vertical_padding"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:scaleType="fitCenter" />
<ImageView
android:id="@id/abs__up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
android:layout_marginRight="-8dip"
android:contentDescription="@null"
android:src="?attr/homeAsUpIndicator"
android:visibility="gone"
tools:ignore="ContentDescription" />
</view>
Run Code Online (Sandbox Code Playgroud) 我正在编辑我的问题,以便更好地理解我需要的东西,因为下面的答案没有给我正确的解决方案.所以,我要做的是使用底部的中性按钮创建一个自定义警报对话框.以下是它应该是什么样子的示例:

直到现在我已经使用xml和更改活动的自定义对话框android:theme="@android:style/Theme.Holo.Light.Dialog",所以我可以得到相同的外观和感觉.这是我的xml代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/login_prompt_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="@string/login_prompt_rewards_header"
android:textSize="17sp"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/login_prompt_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_prompt_header"
android:layout_marginTop="5dp"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:text="@string/login_prompt_rewards_text"
android:textSize="15sp" >
</TextView>
<Button
android:id="@+id/log_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_prompt_text"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:background="@drawable/log_in"
android:contentDescription="@string/none" >
</Button>
<Button
android:id="@+id/create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/log_in"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@drawable/create_account"
android:contentDescription="@string/none" >
</Button>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
通过上面的布局我得到了以下结果:

我面临的问题是:如何在自定义对话框中设置中性按钮?我对此并不了解.如果您对我的问题有疑问或者您无法理解该语言,请发表评论,以便我再次给您一个清晰的想法.帮助将不胜感激.
我需要你的帮助以解决android dev中的以下问题.出于某种原因,当我扩展ActioBarActivity时,当我按下EditText组件时,剪切/复制/粘贴按钮会正确显示(见图1).

不幸的是,如果我扩展Activity,工具栏将无法正确显示.您可以在图像2上看到按钮存在,但它们是白色的,用户无法看到它们.我已经调查过,但我不确定如何解决这个问题.

如果你需要我可以分享代码,但我认为这可以很容易地再现.
提前致谢.
保罗
android android-layout android-theme android-activity android-actionbaractivity
我用XML获得了这种风格:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/teal_500</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/teal_700</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/light_blue_500</item>
<!-- needed to suppress the old ActionBar when using the new Toolbar -->
<item name="android:windowActionBar">false</item>
<!-- …Run Code Online (Sandbox Code Playgroud) 我正在Android使用一个应用程序Toolbar,Custom style但当我正在运行该应用程序时,我收到以下错误:
引起:java.lang.IllegalStateException:此Activity已经有一个由窗口装饰提供的操作栏.不要在主题中请求Window.FEATURE_SUPPORT_ACTION_BAR并将windowActionBar设置为false以使用工具栏.
Styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColor">@color/textColorPrimary</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="android:textColorSecondary">@color/textColorPrimary</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<style name="MyMaterialTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="MyEditTextTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Used for the bottom line when not selected / focused -->
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:colorBackground">@color/colorBackground</item>
<item name="android:textStyle">bold</item>
<item name="android:endColor">@color/colorPrimary</item> …Run Code Online (Sandbox Code Playgroud) 我创建我的主题以与应用程序一起使用,主题的父级是 Theme.AppCompat.Light.NoActionBar
顺便说一句,我想要白色背景和黑色文字.
这是适配器代码
val adapter = ArrayAdapter.createFromResource(activity,
R.array.email_type_array, android.R.layout.simple_spinner_item)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
child.spinner.adapter = adapter
Run Code Online (Sandbox Code Playgroud)
有没有简单的方法来改变Android中的Spinner下拉颜色?
当我resolveAttribute()用来找出颜色值时?attr/colorControlNormal,我得到了236:
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true);
int color = typedValue.data;
// 236
Run Code Online (Sandbox Code Playgroud)
但是当我使用带有以下TextView元素的XML布局时:
<TextView
android:id="@+id/textView"
style="?android:attr/textAppearance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/colorControlNormal"
android:text="@null" />
Run Code Online (Sandbox Code Playgroud)
...以及以下Java代码:
View textView = findViewById(R.id.textView);
int color = ((TextView) textView).getCurrentTextColor();
// -1979711488
Run Code Online (Sandbox Code Playgroud)
我的颜色值是 -1979711488
为何结果有所不同?我希望得到相同的颜色值,但它们不是.
第二种方法(我相信)返回正确的颜色值.为什么我的第一种方法错了?
我宁愿获得颜色值?attr/colorControlNormal而不需要使用实际元素.我怎样才能做到这一点?