2015-08-10 20 views
8

nasıl ayarlanır? WearableListView listesini yapıyorum. Sorun şu ki bu ayar android: layout_height = "20dp" yardımcı olmadı enter image description hereWearableListView öğesi yüksekliği

Bu durumda yükseklik nasıl ayarlanır? Android Wear örnek projeler Bildirimler ve Zamanlayıcı da onlar sadece atribute android ayarlamak: layout_height = "80dp". Ama ben android projelerinde kurmaya çalıştım: layout_height = "20dp" ama yardımcı olmadı! (Aşağıdaki projemin kaynak kodudur):

list_item.xml:

<?xml version="1.0" encoding="utf-8"?> 
<base.mobitee.com.mobiteewatch.adapter.HolesListItemLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="20dp" 
    android:gravity="center_vertical" > 

    <TextView 
     android:id="@+id/text_hole" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="sans-serif-light" 
     android:gravity="center" 
     android:textSize="@dimen/list_item_text_size" /> 
</base.mobitee.com.mobiteewatch.adapter.HolesListItemLayout> 

HolesListItemLayout.java:

public class HolesListItemLayout LinearLayout WearableListView.OnCenterProximityListener uygular uzatır { özel TextView'un mName; özel final int mFadedTextColor; özel final int mChosenTextColor;

public HolesListItemLayout(Context context) { 
    this(context, null); 
} 

public HolesListItemLayout(Context context, AttributeSet attrs) { 
    this(context, attrs, 0); 
} 

public HolesListItemLayout(Context context, AttributeSet attrs, 
          int defStyle) { 
    super(context, attrs, defStyle); 
    mFadedTextColor = getResources().getColor(R.color.grey); 
    mChosenTextColor = getResources().getColor(R.color.black); 
} 

// Get references to the icon and text in the item layout definition 
@Override 
protected void onFinishInflate() { 
    super.onFinishInflate(); 
    mName = (TextView) findViewById(R.id.text_hole); 
} 

@Override 
public void onCenterPosition(boolean animate) { 
    mName.setTextSize(18); 
    mName.setTextColor(mChosenTextColor); 
} 

@Override 
public void onNonCenterPosition(boolean animate) { 
    mName.setTextColor(mFadedTextColor); 
    mName.setTextSize(14); 
} 

}

HolesListAdapter.java: Ben fikrim var

public class HolesListAdapter extends WearableListView.Adapter { 
    private final Context mContext; 
    private final LayoutInflater mInflater; 

    public HolesListAdapter(Context context) { 
     this.mContext = context; 
     mInflater = LayoutInflater.from(context); 
    } 

    @Override 
    public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     return new WearableListView.ViewHolder(
       mInflater.inflate(R.layout.list_item_hole, null)); 
    } 

    @Override 
    public void onBindViewHolder(WearableListView.ViewHolder holder, int position) { 
     TextView text = (TextView) holder.itemView.findViewById(R.id.text_hole); 
     text.setText(mContext.getString(R.string.hole_list_item) + " " + (position + 1)); 
     text.setTextColor(mContext.getResources().getColor(android.R.color.black)); 
     holder.itemView.setTag(position); 
    } 

    @Override 
    public int getItemCount() { 
     return Preferences.HOLES; 
    } 
} 

cevap

-1

. Listeyi FrameLayout konteynerine yerleştirin. Ve konteyner listesinin yüksekliğini değiştirerek öğe yüksekliği değişir. Sonuç:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="90dp" 
     android:layout_centerInParent="true"> 

     <android.support.wearable.view.WearableListView 
      android:id="@+id/wearable_list_game_options" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:dividerHeight="0dp" 
      android:scrollbars="none"/> 
    </FrameLayout> 

</RelativeLayout> 

enter image description here

6

WearableListView üç öğe aynı anda sadece ekrana sert kodlanmış - bu üçe liste görünümünün yüksekliğini bölerek madde yüksekliğini ölçen ... yani yok İstediğiniz şeyi yapmanın pratik bir yolu. Bu kalıntılar layout_margin = "5DP"

+0

CRUD:

Ben – Trejkaz

-1

içeride bir LinearLayout ekleyin ... yazı tipi daha büyük hale ve

android set öneririz: layout_height = "50dp" android benim yapılandırma ekranım için kullanmak benim planları, ama bilmek güzel. Şimdi tekrar görüş almaya gitmek zorundayım.