Search code examples
androidandroid-layoutandroid-intentandroid-wheel

WheelView not filling parent


I am using Yuri Kanivets's WheelView control and I am finding that it is not filling the parent view even though the layout XML is specifying it to do so.

Here is an image of what I mean:

enter image description here

Here is the layout XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#00000000">

    <LinearLayout
        android:orientation="vertical"
        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="5dp"
            android:paddingBottom="5dp"
            android:background="@drawable/picker_bar">
            <Button
                android:id="@+id/repeatButton"
                android:textColor="#FFF"                
                android:layout_gravity="center_vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/picker_button_selected"
                android:paddingTop="8dp"
                android:paddingBottom="8dp"
                android:paddingLeft="15dp"
                android:paddingRight="15dp"
                android:layout_marginLeft="7dp"
                android:gravity="center"
                android:textSize="16sp"
                android:text="Repeat"/>
            <Button
                android:id="@+id/DelayButton"
                android:layout_gravity="center_vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/picker_button_unselected"
                android:paddingTop="8dp"
                android:textColor="#FFF"
                android:paddingBottom="8dp"
                android:paddingLeft="15dp"
                android:paddingRight="15dp"  
                android:layout_marginLeft="10dp"  
                android:gravity="center"
                android:textSize="16sp"         
                android:text="Delay"/>
            <Button
                android:id="@+id/doneButton"
                android:layout_marginLeft="10dp"
                android:layout_gravity="center_vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/picker_button_unselected"
                android:textColor="#FFF"
                android:paddingTop="8dp"
                android:paddingBottom="8dp"
                android:paddingLeft="15dp"
                android:paddingRight="15dp"
                android:gravity="center"
                android:textSize="16sp"
                android:text="Done"/>               
        </LinearLayout>

        <include layout="@layout/repeat_view"/>
        <include layout="@layout/delay_view"/>
   </LinearLayout>
</RelativeLayout>

Here is the repeat/delay view XML (they are both pretty much the same):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/wheelRepeat"
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:background="@drawable/layout_bg"
    android:layout_width="fill_parent">
    <LinearLayout 
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_width="fill_parent"
        android:paddingTop="4dp"
        android:paddingBottom="4dp"     
        android:orientation="horizontal">
       <desiderata.ihunt.resources.WheelView 
            android:id="@+id/activeRepeat"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"/>             
       <desiderata.ihunt.resources.WheelView 
            android:id="@+id/minsRepeat"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="2"/>
       <desiderata.ihunt.resources.WheelView 
            android:id="@+id/secsRepeat"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="2"/>                 
    </LinearLayout>
</LinearLayout>

Here is how I'm adding the view:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.settings);

            ...

I've looked through the WheelView source, but it's not obvious where the width of the entire control is being set and if the wheel control is somehow also controlling the width of the parent layout.

This is running on the latest SDK. Is there something obvious that I am missing?


Solution

  • The LinearLayout which contains the three desiderata.ihunt.resources.WheelView has android:layout_width="fill_parent", but the WheelViews themselves have:

    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    

    That being said and if I understand the question correctly means, that if the width of the three Wheels is less that the width of the parent (in this case the LinearLayout which contains the three desiderata.ihunt.resources.WheelView) - then you'll have to either strech the Wheels of fill the LinearLayout with a solid color (black for example) to hide what's behind it.