1

I have a preference in which I am setting my title and summary programmatically

PreferenceScreen screen= parent.getPreferenceManager().createPreferenceScreen(context);   
screen.setTitle(R.string.color_title);         
screen.setSummary(R.string.color_summary);

Now I want to apply an icon to my preference.

screen.setIcon(shape);

But this icon is aligned to left of my title and summary Is there any way to right align this icon in my preference?

Goku
  • 9,102
  • 8
  • 50
  • 81
SuperCode
  • 11
  • 2

2 Answers2

2

Use the following attribute in preference:

android:widgetLayout="@layout/preference_right_chevron_layout"

Additionally, create a layout in layout directory with the image.

This will position the icon on the right side of preference item.

krisDrOid
  • 3,252
  • 3
  • 25
  • 36
0

sharedPreference is keyValue store function its store only primitive datatype. If you want to store image or icon it's cant saved. You can save image path in shared preference. If you dont know path then you Should change image into bitmap and bitmap to string then save and want to show then convert string to bitmap and bitmap show in imageview. please prefer below link How can I store images using sharedpreference in android?

Ramchandra Singh
  • 530
  • 4
  • 15
  • 3
    This is off subject. The question is about PreferencesScreen which is a specific way to design Settings screens. – ddc Mar 25 '20 at 10:08