Reputation: 97
Code :
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="pref_cb"
android:title="@string/pref_cb_title"
android:summary="@string/pref_cb_summ"
android:defaultValue="true" />
<Preference
android:title="Starts Intent"
android:key="startIntent">
<intent android:action="com.example.app.APPACTIVITY"/>
</Preference>
<com.example.app.AdmobPreference android:layout="@layout/admob_layout"/>
</PreferenceScreen>
and I set it using fragment so,
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
and then add fragment to activity by,
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
Question :
Now as AdmobPreference is a banner ad (added as custom preference) I want it to be at the bottom of the screen. and I also want to be able to control the gap between startIntent preference and admobPreference. Is there any way I can do that?
What I have tried:
I have tried to use android divider, but that did not worked. when should I set divider and divider height ? (and how ? as casting ad view to LinearLayout.LayoutParams gave me class caste exception) will divider work? for this I refered link1 and link2
link2 actually customize all preference, but I want to customize divider of only 2 elements
I also tried using marginTop but that does not work. I also tried to apply different styling element in "LinearLayout" element, present in admob_layout. I did not tried padding as I think padding will make the blanks space clickable, which I dont want.
There is "space" tag but I have not actually tried that still reading about it.
Edit:
I think using weight sum is best option because only that can guarantee that adview is at bottom of the screen. Otherwise one needs to calculate height of the screen and accordingly put divider height/marginTop values. Thanks.
Upvotes: 0
Views: 999
Reputation: 3134
just create a blank tableRow or any other layout (without showing any action/text/color),define its height and width and put where you want Gap.
Upvotes: 1