<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
<AutoCompleteTextView
android:id="@+id/autoComplete"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:background="@drawable/black_rounded_borders" />
</RelativeLayout>
I added the useless LinearLayout just to avoid initial focus on the AutoCompleteTextView when the Activity is launched
drawable/black_rounded_borders.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFFFF" />
<stroke
android:width="2dp"
android:color="@color/selector_black_border" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
color/selector_black_border.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="#FF269ff5"/>
<item android:state_pressed="true" android:color="#FF269ff5"/>
<item android:state_selected="true" android:color="#FF269ff5"/>
<item android:state_focused="false" android:color="#FF000000"/>
<item android:state_pressed="false" android:color="#FF000000"/>
<item android:state_selected="false" android:color="#FF000000"/>
</selector>
Activity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
autoComplete = (AutoCompleteTextView) findViewById(R.id.autoComplete);
Log.d("hasFocus", autoComplete.hasFocus() + "");
Log.d("isSelected", autoComplete.isSelected() + "");
Log.d("isPressed", autoComplete.isPressed() + "");
//All the above are false
}
Though all the states related the blue(#FF269ff5) color are false. I still get the border in blue color. Also if I change the order of states in the color/selector_black_border.xml file, like all false first and then trues, then I get the black border. Its like only the first color works.
What am I missing?
Thank You.