2

I use SherlockPreferenceActivity for Preference activity from a xml file. Code below:

public class Setting extends SherlockPreferenceActivity
{
protected void onCreate(Bundle paramBundle)
{
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.setting);
}

Everything work fine but i need the margin left and right is 0dip (the pic below) enter image description here

I had try to find in ABS source code but failed to custom it. Anyone has do it before?

Update: I upload more detail image enter image description here

setting.xml content:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
    <PreferenceCategory android:title="@string/system_setting" >
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="mode_on_off"
            android:summaryOff="Sub Setting 1"
            android:summaryOn="Sub Setting 1 On"
            android:title="Setting 1" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="filter_on_off"
            android:summaryOff="Sub Setting 2"
            android:summaryOn="Sub Setting 2 On"
            android:title="Setting 2" />
        <CheckBoxPreference
            android:defaultValue="false"
            android:key="screen"
            android:summaryOff="Sub Setting 3"
            android:summaryOn="Sub Setting 3 on"
            android:title="Setting 2" />

    </PreferenceCategory>
</PreferenceScreen>
DzungPV
  • 1,561
  • 3
  • 18
  • 24

1 Answers1

0

use this way:

enter image description here

in Activity:

import android.os.Bundle;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockPreferenceActivity;

public class MainActivity extends SherlockPreferenceActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // setContentView(R.layout.custom_infowindow);
        final ActionBar actionBar = getSupportActionBar();
        actionBar.setCustomView(R.layout.custom_infowindow);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);

        addPreferencesFromResource(R.xml.test);
    }

}

custom_infowindow.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Right Now Event"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FF0000" />

    <View
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:background="@color/_blue" />

</LinearLayout>
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177