2016-06-01 21 views
0

Ich möchte dies zu schaffen, und ich habe ziehbar in ihnen zusammen mit Textview verwendet:Android: Wie Textview sichtbar mit Polsterung machen

enter image description here

Aber ich bin nicht die Textview in der Mitte immer noch ganzer Text ist sichtbar aufgrund der Polsterung. Wie ändere ich meinen vorhandenen Code so, dass er so aussieht? Momentan möchte ich nicht das Bild und nur den Text und die Tasten.

rounded_edge.xml

<?xml version="1.0" encoding="UTF-8"?> 

    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" 
    > 


     <solid android:color="#FFFFFF"/> 

     <stroke android:width="5dp" 
      android:color="#000000"/> 


     <!--<padding android:left="30dp" 
      android:top="350dp" 
      android:right="250dp" 
      android:bottom="10dp"/>--> 

     <gradient android:startColor="#D2E0E2" android:endColor="#D2E0E2"/> 

    <corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp" 
     android:topLeftRadius="5dp" android:topRightRadius="5dp"/> 

    </shape> 

yelp_biz_detail.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:layout_centerInParent="true" 
    > 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/rounded_edge" 
     android:layout_marginTop="30dp" 
     android:layout_marginLeft="30dp" 
     android:layout_marginRight="30dp" 
     android:paddingLeft="30dp" 
     android:paddingTop="350dp" 
     android:paddingRight="250dp" 
     android:paddingBottom="10dp"/> 
     android:textAlignment="center" 

     android:gravity="center" 
     /> 


</LinearLayout> 

Lösung ist:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:layout_centerInParent="true" 
    > 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" 
     android:layout_marginTop="30dp" 
     android:layout_marginLeft="30dp" 
     android:layout_marginRight="30dp" 
     android:layout_marginBottom="150dp" 
     android:background="@drawable/rounded_edge" 
     > 
    <TextView 
     android:id="@+id/textView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="30dp" 
     android:paddingTop="30dp" 
     android:paddingRight="25dp" 
     android:paddingBottom="10dp" 
     android:textAllCaps="true" 
     /> 


</LinearLayout> 
    </LinearLayout> 
+0

Ich könnte dieses Problem lösen, indem eine lineare Layout in einer anderen linearen Layout zugab und das Problem gelöst. – Nick

+0

Könnten Sie bitte unten antworten und es als akzeptiert markieren, anstatt die Frage zu bearbeiten? Vielen Dank? –

Antwort

1

Ich denke du meinst 35dp statt 350dp in android:paddingTop="350dp" und 25dp statt 250dp in android:paddingRight="250dp" in yelp_biz_detail.xml Datei

+0

danke @Omar Al Halabi. – Nick

0

rounded_edge.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" > 

    <solid android:color="#FFFFFF" /> 

    <corners android:radius="5dp" /> 

    <padding 
     android:bottom="16dp" 
     android:left="16dp" 
     android:right="16dp" 
     android:top="16dp" /> 

</shape> 

yelp_biz_detail.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#99000000" 
    android:padding="32dp" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:gravity="center_horizontal" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/imageView" 
      android:layout_width="160dp" 
      android:layout_height="160dp" 
      android:src="@drawable/your_image" /> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:background="@drawable/rounded_edge" 
      android:gravity="center" 
      android:text="Your text..." /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="48dp" 
      android:orientation="horizontal" > 

      <Button 
       android:id="@+id/button_one" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="8dp" 
       android:layout_weight="1" 
       android:text="Button One" /> 

      <Button 
       android:id="@+id/button_two" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="8dp" 
       android:layout_weight="1" 
       android:text="Button Two" /> 
     </LinearLayout> 
    </LinearLayout> 

</RelativeLayout> 
Verwandte Themen