2010-07-24 2 views
2

안녕하세요, 저는 활동이 있고 일부 단추와 textviews가 있고, 안에 텍스트가있는 사각형을 그리기를 원합니다. 온라인에서 몇 가지 예를 보았지만 모두보기에 내 생각을 만들고, onDraw를 재정의하고,이보기를 내 레이아웃으로 설정한다고 말했지만, 이미 내 레이아웃이 있습니다.어떻게 안드로이드에 직사각형을 그리고 내부에 텍스트를 넣은 다음 배치 할 수 있습니까?

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    TextView baramzona = (TextView) findViewById(R.id.TextView01); 
    baramzona.setText(R.string.baram_zona_textview); 
    final Button pocniparking = (Button) findViewById(R.id.ButtonStart); 
    final TextView momentalnazona = (TextView) findViewById(R.id.TextView02); 



    //momentalnazona.setText("Моментално се наоѓате во зоната"); 
    pocniparking.setText(R.string.btn_Start_Parking); 
    pocniparking.setEnabled(false); 

    } 
    } 

어떤 아이디어가 있습니까?

+2

자신 만의보기를 만드는 것은 잔인한 소리입니다. TextView에 배경이나 테두리를 설정할 수 있는지 여부를 살펴 보겠습니다. – MatrixFrog

+0

이 http://www.androidpeople.com/android-textview-border/이 발견되었습니다. 시도해 보겠습니다. – Simon

답변

1

이것은 일시적인 해결책이지만 일종의 목적입니다. 기본적으로 TextView를 테이블에 넣고 외곽선의 표 배경을 설정하고 외곽선 크기의 여백을 설정할 수 있습니다. 희망이 도움이됩니다.

<TableLayout android:id="@+id/TableLayout01" 
    android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:background="#55771B"> 
<TextView android:text="@+id/TextView01" 
android:id="@+id/TextView01" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_marginLeft="3px" 
android:layout_marginBottom="3px" 
android:layout_marginRight="3px" 
android:layout_marginTop="3px" 
android:background="#010101"/> 
</TableLayout> 
관련 문제