简体   繁体   中英

How can I shape a webview on Android?

I want to padding my textview without disturbing my background image but when I made padding on relative layout it crops my background from all around moreover when I try to padding from textview itcrops my text

here is my code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TesbihMainActivity" >

    <ImageView
        android:id="@+id/backroundimage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:scaleType="centerCrop"
        android:src="@drawable/tesbihbackround"
         />

    <TextView

        android:id="@+id/display"
        android:layout_width="fill_parent"
        android:layout_height="63dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="#e9ebec"
        android:text=" 385 "
        android:gravity="center"
        android:textSize="52dp"
        android:textColor="#3c677b"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

Use Margin on your TextView, instead of Padding.

Padding adds space inside the View. Margin adds space outside!

For Example: Padding on TextView will move the content of the TextView away from the borders of the TextView. Margin on TextView will move the whole TextView away from its parent's borders.

You can use android:layout_margin="" on your textView instead of android:padding="" . This will make a margin with inserted value in TextView to all the directions (Top,Bottom,Left and Right) of the textView

You can also use these if you want a specific margin applied:

android:layout_marginLeft=""
android:layout_marginTop=""
android:layout_marginRight=""
android:layout_marginBottom=""

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