2014-11-23 131 views
0

可以說我有一個相對佈局的背景圖像。該圖像是一個圓圈,在圓圈內部,我用單個字母放置了文本視圖,但無論如何,我怎樣才能將文本視圖保留在圓圈內? 我使圖像始終保持相同的分辨率,但有時候這封信仍然在圓圈外。android相對佈局和圖像背景

P.S.創建所有的高DPI,中DPI等,不會工作

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/ScrollView1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:gravity="center" > 

    <TextView 
     android:id="@+id/Title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#000000" 
     android:gravity="center" 
     android:text="Majore C " 
     android:textColor="#FFFFFF" 
     android:textSize="40sp" /> 

    <RelativeLayout 
     android:layout_width="1090dp" 
     android:layout_height="1920dp" 
     android:background="@drawable/backright3" > 

     <TextView 
      android:id="@+id/A" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/E" 
      android:layout_alignBottom="@+id/E" 
      android:layout_toRightOf="@+id/E" 
      android:background="@drawable/bg_red" 
      android:text=" A " 
      android:textColor="@color/Red" 
      android:textSize="20sp" /> 
+0

發佈你的嘗試代碼 – Rami 2014-11-23 16:48:07

+0

其有點太大,很多文件,你有什麼建議嗎?當我切換到不同的屏幕和方面時如何保持圈中的文本視圖 – user3780144 2014-11-23 17:09:35

+0

我已經提出了建議,但我必須確定你確實需要什麼。這就是爲什麼我要求查看你的代碼。只是xml文件,嘗試刪除額外的意見,如果它太大,並張貼 – Rami 2014-11-23 17:14:49

回答

0

不同的佈局試試這個:

<RelativeLayout 
    android:layout_width="1090dp" 
    android:layout_height="1090dp" 
    android:background="@drawable/backright3"> 

    <TextView 
     android:layout_width="1090dp" 
     android:layout_height="1090dp" 
     android:text="A" 
     android:id="@+id/A" 
     android:textColor="#ffffff" 
     android:textSize="20sp" 
     android:gravity="center" 
     android:background="@drawable/bg_red" 
     android:textColor="@color/Red" 
     android:layout_margin="6dp" /> 
</RelativeLayout> 

更新(許多的TextView S):

<RelativeLayout 
      android:layout_width="1090dp" 
      android:layout_height="1090dp" 
      android:background="@drawable/backright3"> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="1090dp" 
       android:layout_height="1090dp" 
       android:layout_margin="6dp" 
       android:gravity="center"> 
       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="A" 
        android:id="@+id/A" 
        android:textColor="#ffffff" 
        android:textSize="20sp" 
        android:background="@drawable/bg_red" 
        android:textColor="@color/Red"/> 
       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="B" 
        android:id="@+id/B" 
        android:textColor="#ffffff" 
        android:textSize="20sp" 
        android:background="@drawable/bg_red" 
        android:textColor="@color/Red"/> 

       //Other texts....... 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Z" 
        android:id="@+id/Z" 
        android:textColor="#ffffff" 
        android:textSize="20sp" 
        android:background="@drawable/bg_red" 
        android:textColor="@color/Red"/> 
      </LinearLayout> 
</RelativeLayout> 

PS:文本的數量取決於textSize父版面寬度

+0

所以如果我沒有隻有一個字母,我有一百,我指定他們的寬度和高度,他們將永遠在圖像中的相同位置? – user3780144 2014-11-23 17:57:39

+0

你是什麼意思關於「如果我沒有隻有一封信,我有一百個」?與一百個字母或一百個TextView相同的TextView,每個都有一個字母? – Rami 2014-11-23 18:00:12

+0

100 textview與每個人都有一個字母,我把他們放在圖像背景,並希望永遠在那裏不管什麼 – user3780144 2014-11-23 18:05:57