2014-11-23 143 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