2013-06-14 6 views
0

나는 서로 옆에 설정하는 텍스트보기 쌍을 가지고 있으며, 불행하게도 필자는 불행히도 필자가 코드별로 txtView2를 올바르게 설정하지 않는 한 영역을 가지고있다. 바닥. 연료 스테이션보기 (View To Fuel Stations)를 보시면 여기를 클릭하십시오. 나는 무엇을 여기에서 놓쳤 느냐? 여기 내 화면 샷입니다.여러 텍스트보기 설정 Android

enter image description here

그리고 여기 레이아웃 내 코드입니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".MainActivity" > 

<TextView android:id="@+id/txtViewGPS" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:textSize="20sp" 
    android:textColorLink="#FFFF00" 
    android:textStyle="bold"/> 
<TextView android:id="@+id/txtView_5" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_below="@+id/txtViewGPS" 
    android:textSize="20sp" 
    android:textColorLink="#FFFF00" 
    android:textStyle="bold"/> 
<TextView android:id="@+id/textView1_1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:singleLine="true" 
    android:text="To view Evacuation Routes - " 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:layout_marginRight="5dp"/> 

<TextView android:id="@+id/txtView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_toRightOf="@id/textView1_1" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:layout_alignParentRight="true"/> 
<TextView android:id="@+id/txtView1_5" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_below="@+id/txtView1" 
    android:textSize="20sp" 
    android:textColorLink="#FFFF00" 
    android:textStyle="bold"/> 
<TextView android:id="@+id/textView2_1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:singleLine="true" 
    android:layout_below="@+id/txtView1_5" 
    android:text="To view shelters - " 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:layout_marginRight="5dp"/> 
<TextView android:id="@+id/txtView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/txtView1" 
    android:text="" 
    android:layout_toRightOf="@id/textView2_1" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:layout_alignParentRight="true"/> 
<TextView android:id="@+id/txtView2_5" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_below="@+id/txtView2_1" 
    android:textSize="20sp" 
    android:textColorLink="#FFFF00" 
    android:textStyle="bold"/> 
<TextView android:id="@+id/textView3_1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:singleLine="true" 
    android:layout_below="@+id/txtView2_5" 
    android:text="To view Fuel Stations - " 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:layout_marginRight="5dp"/> 
<TextView android:id="@+id/txtView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/txtView2" 
    android:layout_toRightOf="@id/textView3_1" 
    android:text="" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:layout_alignParentRight="true"/> 

</RelativeLayout> 
+2

당신은 그들에게 적어도 의미있는'id's 또는를 줄 경우가 쉬울 것이다, 어떤 지적 도와주세요. 의미있는'id'는 코드 작성시에도 도움이 될 수 있습니다. – codeMagic

+0

txtView2와 txtView2_1은 ID가 나에게 문제를 일으키고, txtView2_1 디스플레이는 연료 스테이션을 표시하고 txtView2는 여기를 표시합니다. – yams

+0

txtView2_1 (여기에있는 것)이 아닙니다. "연료 관을 보시려면"을 표시하는 TextView – codebaum

답변

2

에 추가 할 수 있습니다. RelativeLayouts는 이와 같은 간단한 구현에 필요한 것보다 더 복잡합니다.

TableLayout을 예 :

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1_1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:singleLine="true" 
      android:text="To view Evacuation Routes - " 
      android:textSize="20sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/txtView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView3_1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:singleLine="true" 
      android:text="To view Fuel Stations - " 
      android:textSize="20sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/txtView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView2_1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:singleLine="true" 
      android:text="To view shelters - " 
      android:textSize="20sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/txtView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </TableRow> 

</TableLayout> 

있는 LinearLayout 예 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/textView1_1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:singleLine="true" 
      android:text="To view Evacuation Routes - " 
      android:textSize="20sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/txtView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/textView3_1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:singleLine="true" 
      android:text="To view Fuel Stations - " 
      android:textSize="20sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/txtView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/textView2_1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:singleLine="true" 
      android:text="To view shelters - " 
      android:textSize="20sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/txtView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

</LinearLayout> 
+0

예를 들어 주시겠습니까? – yams

+0

당신이 여분의 textviews를 원하는 곳이 어디인지는 모르겠지만 이미지마다 나는 예제를 추가했습니다. – invertigo

+0

느리게 응답하는 현기증에 대해 유감 스럽지만 이렇게했습니다. – yams

0

모바일 사용자는 목록 항목과 같은 전체 영역을 클릭하는 데 익숙합니다. "여기를 클릭하십시오"링크를 없애고 전체 텍스트를 클릭 할 수있게하는 것이 좋습니다. 그런 다음 세로 형 LinearLayout 또는 ListView에 모두 넣을 수 있습니다.

+0

그건 전혀 대답이 아니에요. – yams

+0

이것은 상황에 따라 다릅니다. 어쩌면 텍스트가 도움말/정보 페이지에 표시되고 사용자가 링크를 클릭 할 수 있습니다. –

0

해결책이 처음부터 좋지 않습니다. 하나 대신 2 textView를 사용하려고했기 때문에 해결책이 좋지 않습니다. 화면에서 둘 다 표시 할 수 없거나 사용자가 OS 용으로 더 큰 글꼴을 사용하도록 설정 한 경우 어떻게 될지 생각하십시오. 2 textviews 어쨌든

  1. 사용 및 사용자 정의 만든 레이아웃 (같은 flowLayout) :

    는 여기에 몇 가지 가능한 솔루션을합니다. 단어 대신 textViews의 전체 부분을 차지하므로 권장하지 않습니다.

  2. 하나의 textView와 Html.fromHtml을 사용하고 링크를 클릭하면 처리됩니다.

  3. HTML 내용을 표시하고 링크를 클릭하여 처리하는 webView를 사용하십시오. WebView가 스크롤 할 때 특히 스크롤 가능한 컨테이너 안에 있다면 이상한 문제가 있습니다.

알아두기, 문자열을 strings.xml에 넣어야합니다. 특히 현지화에 좋습니다.

0

txtView2_1은 txtView3_1 오른쪽에 표시하도록 설정해야 할 때 txtView2_1 오른쪽에 표시되도록 설정됩니다 (채우기 스테이션을 보려면).

ID를 더 잘 지정해야합니다. 그것은 너무 혼란 스럽습니다.

+0

그는 그래픽 디자이너를 사용하여 물건을 끌 수 있습니다. relativeLayout을 사용할 때 일반적으로 사용하기가 더 쉽습니다. 그 후에 그는 Alt + Shift + R을 사용하여 ID의 이름을 바꿀 수 있습니다. –

0

이 방법이 효과가 있는지는 잘 모르겠지만 시도해보십시오. 내 의견을 읽는 데 혼란 스러울 수 있습니다.

textView2android:layout_toRightOf="@id/textView2_1"을 제거 시도하고 나는 TableLayout을 3 수평은 LinearLayouts과 수직의 LinearLayout 중 하나에 RelativeLayout의 변경 것이다 그것을

android:layout_alignRight="@+id/textView1" <!-- or whatever is the id of the one above this one 
관련 문제