2017-06-22 16 views
1

まず、私はXamarinとAndroidをプログラミングするのにかなり新しいです。私はSeekbarPreferenceを作成しましたが、レイアウトが正しく表示されないものもあります。値はボックスから落としています(写真参照)。スタイリングandroid.support.v7.preference.SeekBarPreference

enter image description here

私のstyles.xml:

<?xml version="1.0" encoding="utf-8" ?> 
<resources> 
    <style name="MyTheme" parent="MyTheme.Base"> 

    </style> 

    <style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="colorPrimary">#EC6A1E</item> 
    <item name="colorAccent">#EC6A1E</item> 
    <item name="toolbarStyle">@style/custom_toolbar</item> 
    <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material.Fix</item> 
    </style> 

    <style name="custom_toolbar" parent="@style/Widget.AppCompat.Toolbar"> 
     <item name="titleTextColor">#FFFFFF</item> 
    </style> 

    <style name="PreferenceThemeOverlay.v14.Material.Fix" parent="PreferenceThemeOverlay.v14.Material"> 
    <item name="seekBarPreferenceStyle">@style/Preference.SeekBarPreference.Fix</item> 
    </style> 

    <style name="Preference.SeekBarPreference.Fix"> 
    </style> 
</resources> 

ここでは私のsettings.xmlは、私が理解していないが、私は私が使用できるXML属性を見つけることができる方法である

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.preference.PreferenceScreen 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <android.support.v7.preference.SeekBarPreference 
      android:id="@+id/preference_range_seek_bar" 
      android:layout_height="wrap_content" 
      android:key="range" 
      android:title="Range" 
      android:summary="Here you can set the range of your location" 
      android:max="10000" 
      android:defaultValue="500" /> 
    <android.support.v7.preference.SeekBarPreference 
      android:key="favRange" 
      android:title="Favorite Range" 
      android:summary="Here you can set the range of your Favorite location" 
      android:max="10000" 
      android:defaultValue="500" /> 
    <android.support.v7.preference.Preference android:title="Title" android:summary="This is the summary"> 
    </android.support.v7.preference.Preference> 

</android.support.v7.preference.PreferenceScreen> 

ですこれを修正するにはSeekBarPreferenceでGooglesドキュメントを見ると、このSeekBarPreferenceでxml属性の説明を見つけることができません。

私はテーマがあまりにも曖昧だと知っています。しかし、私がそれを働かせたら、私はこれを調整します。

うまくいけば、誰かが私を助けるか、例を持っている可能性が...

答えて

0

同じ問題に遭遇しました。カスタムクラス名でSeekBarPreferenceクラス名を置き換えるあなたのあるpreferences.xmlでSeekBarPreference

public class CustomSeekBarPreference extends SeekBarPreference { 
    private TextView mSeekBarValueTextView; 

    public CustomSeekBarPreference(Context context, 
     AttributeSet attributeSet, 
     int i, int i1) { 
    super(context, attributeSet, i, i1); 
    } 

    public CustomSeekBarPreference(Context context, AttributeSet attributeSet, int i) { 
    super(context, attributeSet, i); 
    } 

    public CustomSeekBarPreference(Context context, AttributeSet attributeSet) { 
    super(context, attributeSet); 
    } 

    public CustomSeekBarPreference(Context context) { 
    super(context); 
    } 

    @Override 
    public void onBindViewHolder(PreferenceViewHolder preferenceViewHolder) { 
    super.onBindViewHolder(preferenceViewHolder); 
    mSeekBarValueTextView = (TextView) preferenceViewHolder.findViewById(android.support.v7.preference.R.id.seekbar_value); 
    if (mSeekBarValueTextView != null) { 
     LayoutParams layoutParams = mSeekBarValueTextView.getLayoutParams(); 
     layoutParams.height = LayoutParams.WRAP_CONTENT; 
     mSeekBarValueTextView.setLayoutParams(layoutParams); 
    } 
    } 
} 

を拡張する新しいクラスを作成し、

ステップ1:ここでは、ソリューション、API 25を実行しているエミュレータのtestionで行きます。

<com.google.xxx.view.CustomSeekBarPreference 
     android:key="cacheLimit" 
     android:title="@string/setting_cache_limit_title" 
     android:dependency="enableCaching" 
     android:defaultValue="20" 
     android:max="40"/> 
関連する問題