Hi I am doing a login page for my project whose xml looks like this
<EditText
android:id="@+id/user_name_id"
android:layout_height="wrap_content"
android:layout_width="300dp"
android:ems="10"
android:singleLine="true"
android:layout_gravity="top|center"
android:gravity="center"
android:layout_marginTop="200dp"
android:hint=" Email Address"
android:textColor="#B3B3B3"
android:textColorHint="#B3B3B3"
android:textCursorDrawable="@drawable/color_cursor"
/>
アバウトコードは、テキスト、ヒント、およびカーソルが#b3b3b3カラーコードであることを示しています。一番下の行も同じカラーコードで欲しかったのです。以下のようにもセレクターを使ってみました。しかし、私のためにうまくいきます。特にエディットテキストの最終的な色を変更するための本物の方法を提案してください。
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:state_pressed="true"
android:drawable="@android:drawable/edittext_pressed"
/> <!-- pressed -->
<item
android:state_focused="true"
android:drawable="@drawable/edittext_focused_blue"
/> <!-- focused -->
<item
android:drawable="@android:drawable/edittext_normal"
/> <!-- default -->
</selector>
そして私はカーソルの色を変更するためにxmlで以下のコードを使用しました
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="1dp" />
<solid android:color="#B3B3B3" />
</shape>
または、誰かが私のために以下のコードを変更してください
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
私はAPIレベル21(lollypop)を使用していましたが、このソリューションはAPIレベル21以上でのみ機能するため、このソリューションを見つけました。レイヤーリストの使用
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="line" >
<solid android:color="#B3B3B3" />
</shape>
</item>
<item android:top="-2dp" android:right="-2dp" android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="0.1dp"
android:color="#B3B3B3" />
</shape>
</item>
</layer-list>
21未満のAPIレベルに使用すると、例外が発生します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加