简体   繁体   中英

How to remove space around an android TimePicker

I am unable to remove the space around the TimePicker: I am scaling the TimePicker down to 40% but there is a lot of space around the TimePicker, which I am not able to remove.

I am using translationX and translationY to position the TimePicker.

Please find below the xml (layout) code:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:orientation="vertical" >

    <TimePicker
        android:id="@+id/timePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleX="0.4"
        android:scaleY="0.4"
        android:translationX="-60dp"
        android:translationY="-20dp"
        android:background="#FFDDAA00" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Below the time spinner" />

</LinearLayout>

Please find below the screenshot in the simulator: http://www.pixentral.com/show.php?picture=1T9y7rt22pzeDwounqG6i5z9YgRMYA

As you can see the gap between the TimePicker and the Text below it is the space that I am unable to remove. I set the backgroud of the TimePicker to highlight the actual TimePicker and the space around it.

Try something like -

android:layout_marginTop="-10dp"

and

android:layout_marginLeft="-10dp"

Reduce the value as per your requirement.


EDIT :

Try removing padding and margin from your activity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM