2011-03-08 1 views
4

아래 작성해야 할보기가 있습니다. 다음 XML을 가지고 있지만 텍스트가 나타나지 않고 높이가 내용을 래핑하는 대신 전체 부모를 채 웁니다. 아래 스크린 샷을 만드는 데 도움을 주시면 감사하겠습니다.안드로이드보기에서 둥근 사각형 안에 텍스트를 어떻게 삽입합니까?

playing.xml

<View 
    android:background="@drawable/rounded_edges" 
    android:text="Current Track" 
    android:textColor="#FFFFFF" 
    android:id="@+id/current_track" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:editable="false"> 
</View> 

rounded_edges.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
    <solid android:color="#1F1F1F"/> 
    <corners android:radius="5px"/> 
    <padding android:left="20dp" android:top="20dp" android:right="20dp" android:bottom="20dp" /> 
</shape> 

view

답변

4

먼저 둥근 모서리를위한 하나의 XML 파일을 생성해야 다음, 하나의 선형 레이아웃을 생성하고 설정 그 뒤 땅에 모서리를 둥글게 한 다음 특정 선형 레이아웃에 텍스트보기를 동적으로 추가합니다. 여기

<LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/your_rounded_edges_xml_file" 
      android:orientation="vertical" 
      android:layout_marginRight="10dp" 
      android:id="@+id/linearLayout"> 

</LinearLayout> 

내가 각보기의 3 개 각 모양을, 귀하의 의견의 더 나은 디자인을 내 둥근 모서리 XML 파일

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

<stroke android:width="1dp" 
     android:color="#ababab" 
     /> 

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

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

0

를 부착하므로 UI를 디자인하고 각 도형에 맞게 텍스트를 정렬하는 것이 더 쉽다는 점입니다.

+0

예제를 제공 할 수 있습니까? – Bear