2016-07-11 4 views
1

enter image description here Ich entwickle eine Android App. Dynamisch habe ich den Namen erstellt (vom Server erhalten), aber jetzt muss ich farbige Rechtecke gleicher Höhe und Breite und etwas Textansicht hinzufügen.Wie füge ich farbige Rechtecke mit Textansicht hinzu

Ich habe das Bild angehängt, das ich entwickeln muss.

Wie kann ich das erreichen? Leinwand verwenden? Ich finde es sehr schwierig.

image

+0

Verwendung Textview und otherTextView in linear-Layout mit Ausrichtung horizontal ... – sushildlh

+0

Ihren XML-Code einfügen hier –

+0

ich Rechtecken farbig haben muß, um den Quellcode – Mark023

Antwort

2

Für Textview, fügen Sie einfach Polsterung und Hintergrund achive diese :) Try this:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#BBBBBB" 
    tools:context="xyz.mhuy.myapplication.MainActivity"> 

    <RelativeLayout 
     android:id="@+id/relativeLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/black" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="HelloWorld" 
      android:padding="10dp" 
      android:textColor="#ffffff" 
      android:gravity=""/> 

     <TextView 
      android:id="@+id/button2" 
      android:padding="10dp" 
      android:background="#ff0000" 
      android:textColor="#ffffff" 
      android:textStyle="bold" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="next" 
      android:layout_alignParentRight="true"/> 

    </RelativeLayout> 
</LinearLayout> 

Oben ist, was du meinst? das Ergebnis ist: enter image description here

+0

Erstellt dies ein farbiges Rechteck mit Textansicht von schwarzer Farbe darin? – Mark023

+0

Ich bearbeite nur meine Antwort :) – alway5dotcom

+1

Danke .... :) – Mark023

Verwandte Themen