当我设置api级别24时,TextView
和Button
的文本颜色不会从xml改变,我面临着一个基本问题。它在预览中显示更改的颜色,但是当应用程序是安装在设备上,我还没有找到任何解决方案,即使我不知道它为什么会发生,这是我的xml文件。
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
android:id="@+id/dragView"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_height"
android:background="@color/bottom_grey_color"
android:paddingRight="@dimen/bottom_margin"
android:paddingLeft="@dimen/bottom_margin"
>
<include layout="@layout/cart_layout"
></include>
<TextView
android:id="@+id/tvTotalPrice"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:text="Rs: 20898789"
android:gravity="center_vertical"
android:textColor="@color/white"
android:layout_toRightOf="@+id/cart_layout"
android:paddingLeft="10dp"/>
<ImageView
android:layout_width="40dp"
android:layout_height="30dp"
android:layout_centerHorizontal="true"
android:src="@mipmap/bottom_bar"
/>
<Button
android:id="@+id/btnCheckout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14sp"
android:gravity="center_vertical|right"
android:text="Check Out"
android:textColor="@color/app_color"
android:layout_alignParentRight="true"
android:background="@color/white"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
这里是Gradle文件..
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.xxxxxxx"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.sothree.slidinguppanel:library:3.3.1'
compile 'com.android.support:design:24.0.0-alpha1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:24.0.0-alpha1'
testCompile 'junit:junit:4.12'
}
这是样式文件..
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.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.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
颜色文件......
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
<color name="bottom_grey_color">#b5b5b5</color>
<color name="app_color">#2e318e</color>
<color name="bg_color">#ebebeb</color>
<color name="cart_bg_color">#da0000</color>
</resources>
清单代码..
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".Activity.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>
</application>
答案 0 :(得分:1)
也许您有值-v21文件夹,文字颜色为白色(或未更改)。检查一下,让我知道。我遇到了同样的问题,但是这样修好了。