TextViews 및 EditTexts가있는 TableLayout이 필요하며 크로스 워드 퍼즐과 같아야합니다.TableLayout 행의 TextView 및 EditText에 동일한 높이를 설정 하시겠습니까?
나는 LinearLayout, width=0dp and weight=1,
으로이 테스트를했지만 내가 원하는처럼이 일을하지 않았다. 그런 다음 TableLayout을 사용하여 테스트 해 보았습니다. 솔루션에 가깝다고 생각합니다. XML이나 Java에서 높이와 너비를 테스트했지만 작동하지 않았습니다. 내 문제는 이제 모든 TextViews가 EditText보다 더 얇아서 왜 어떻게 보이게 할 수 있는지 모르겠습니다.
XML-파일 :
<!-- activity_sraetsel_main.xml -->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</TableLayout>
<!-- activity_sraetsel_row.xml -->
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableRow"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
</TableRow>
<!-- activity_sraetsel_edittext.xml -->
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/cell_border"
android:id="@+id/textView"
android:inputType="textCapCharacters"
android:gravity="center_horizontal"
android:maxLength="1">
</EditText>
<!-- activity_sraetsel_textview.xml -->
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/cell_border"
android:id="@+id/textView"
android:textSize="6.5sp"
android:singleLine = "false" >
</TextView>
<!-- cell_border.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dp" android:color="#515151"/>
<padding android:left="10dp" android:top="5dp"
android:right="10dp" android:bottom="5dp" />
</shape>
및 자바 부분, 내가 모두 함께 넣어 :
TableLayout table = (TableLayout) this.findViewById(R.id.table);
for (int y = 0; y < hoehe; y++) {
// Inflate your row "template" and fill out the fields.
TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.activity_sraetsel_row, null);
for (int x = 0; x < breite; x++) {
if (raetsel[y][x].startsWith(",", 1)) {
EditText eText = (EditText) LayoutInflater.from(this).inflate(R.layout.activity_sraetsel_edittext, null);
if (!(raetsel[y][x].startsWith("a"))) {
eText.setText(raetsel[y][x].substring(0, 1));
} //if
eText.setWidth(60);
eText.setHeight(60);
row.addView(eText);
Log.d(TAG, "SRaetselMain, AntwortFeld erstellt");
} else {
TextView vText = (TextView) LayoutInflater.from(this).inflate(R.layout.activity_sraetsel_textview, null);
vText.setText(raetsel[y][x].substring(0, raetsel[y][x].indexOf("|")));
vText.setWidth(60);
vText.setHeight(60);
row.addView(vText);
Log.d(TAG, "SRaetselMain, FrageFeld erstellt");
} //if
} //for
table.addView(row);
} //for
table.requestLayout();
그리고 마지막으로 그것은처럼 보이는 방법 :
EDIT1 : XML 형식의 TextView에 android:layout_height="match_parent"
을 사용하고 setHeight()를 사용하지 않는 경우 활동에서 텍스트 뷰 :
http://i.stack.imgur.com/btzj4.png
: android:layout_weight="1"
및 android:layout_height="0dp"
와 그것이 지금은 TextViews없이 만 글고 치기로 테스트했습니다, 나는 것을 발견
EDIT1
같은 동일 보인다 문제는 textSize입니다.android:textSize="6.5sp"
옵션없이 TextView를 만들면 작동합니다. 그러나 텍스트가 크고 불행히도 나는이 텍스트가 작게 필요합니다.
EDIT3 : 내가있는 LinearLayout과 두 TextViews와 함께이 시도했습니다 . 나는이 두보기가 같은 높이에 있다는 것을 어떻게 바꿀 수 있는지 정말로 모른다.
http://i.stack.imgur.com/wIENf.png
이 문제에 대해 도움을 주셔서 감사합니다. XML에서TextView
에 대한
스크린 샷 이미지 링크가 작동하지 않습니다. –
고마워요! 이제 작동합니다. – SirArt