2016-07-11 11 views
1

enter image description here私はAndroidアプリを開発しています。 動的に私は(サーバーから取得した)名前を作成しましたが、今度は、同じ高さと幅のテキストのある色付きの矩形を追加する必要があります。テキストビューに色付き長方形を追加するには

開発する必要がある画像を添付しました。

どうすればこの問題を解決できますか?キャンバスを使う?私はそれが非常に難しいと思っています。 TextViewのために

image

+0

利用のTextViewとotherTextView ... – sushildlh

+0

は、ここで私はあなたが今まで開発され、私たちの誰かが改善されるソースコードを共有 –

+0

をあなたのXMLコードを貼り付けそれは – Mark023

答えて

2

、ちょうどこれをachiveするパディングと背景を追加します:) はこれを試してみてください:

上記
<?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> 

はあなたが何を意味するかですか?結果は次のとおりです。オリエンテーション水平と線形レイアウトで enter image description here

+0

これは黒色のtextviewの色付きの矩形を作成しますか? – Mark023

+0

私はちょうど私の答えを編集する: – alway5dotcom

+1

ありがとう.... :) – Mark023

関連する問題