Reputation: 6709
I have this code for a selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Button Focused-->
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/gradient_background"
/>
<!-- Button Focused Pressed-->
<item android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/gradient_background"
/>
<!-- Button Pressed-->
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@android:drawable/ic_search_category_default"
/>
<!-- Button Default Image-->
<item android:drawable="@drawable/gradient_background"/>
</selector>
And in the activity that uses this selector, I have this:
<ListView
android:id="@+id/contactsView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/searchButton"
android:divider="@color/DarkGoldenrod"
android:dividerHeight="0.1dp"
android:listSelector="@drawable/list_selector"
android:drawSelectorOnTop="true" />
Now this is an example of what a listview item looks like when you click it and hold it down...
My Question is: Is there anyway I can make that picture smaller and align it to the right?
Thank you.
Upvotes: 0
Views: 1999
Reputation: 4574
Have a look at point 10 of this Tutorial, get to know how to use your own Layout for a ListView Item and you can do any manipulation you want.
Upvotes: 2
Reputation: 176
I think that Not the good way to do what you want :) .. you have To use Costume Array Adapter for that ..
public class CustomBookItem extends ArrayAdapter<string>{
ArrayList<string> names;
Context context;
public CustomBookItem(Context context, int textViewResourceId,ArrayList<string> names )
{
super(context, textViewResourceId, names);
// TODO Auto-generated constructor stub
this.names=names;
this.context=context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v= convertView;
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v=inflater.inflate(R.layout.custome_listitem, parent,false);
ImageView imageView = (ImageView) v.findViewById(R.id.icon);
Textview name=(Textview)v.findViewById(R.id.name);
imageView.setImageDrawable(r.drawbale.icon_search);
return v;
}
R.layout.custome_listitem
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Textview
android:id="@+id/icon"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2" />
<ImageView
android:id="@+id/icon"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
Upvotes: 0