2016-02-10 4 views
0

Я пытаюсь масштабировать группу изображений и textView, чтобы они масштабировались соответствующим образом на планшетах и ​​телефонах. Good lookingМасштабирование текстовых просмотров и изображений как одна группа в Android

Это выглядит отлично. Это то, что я хочу, чтобы достичь таблицы и также любого другого телефона, потому что он работает только на Nexus S 4" 480x800

Вопрос приходит с каким-либо другим размером экрана: bad result

Я хотел бы масштабировать и текст и изображения, и держать их внутри круга

Мой главный макет:.

<?xml version="1.0" encoding="utf-8"?> 
<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" 
    tools:context="com.example.balazs_gerendai.intentopener.MainActivity"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/circle" /> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:gravity="center|top"> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="192dp" 
      android:text="Hello" /> 
     <ImageView 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:src="@drawable/circle_placeholder"/> 
     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="&lt;Username>" /> 
    </LinearLayout> 
</RelativeLayout> 

круг:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:innerRadius="100dp" 
    android:shape="ring" 
    android:thickness="10dp" 
    android:useLevel="false"> 

    <solid android:color="#ababf2" /> 

</shape> 

ответ

1

Вы можете сделать так:

<?xml version="1.0" encoding="utf-8"?> 
<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" 
tools:context="com.example.balazs_gerendai.intentopener.MainActivity"> 

<!--<ImageView--> 
    <!--android:layout_width="match_parent"--> 
    <!--android:layout_height="match_parent"--> 
    <!--android:src="@drawable/circle" />--> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="@drawable/circle" 
    android:gravity="center"> 
<RelativeLayout 
android:layout_width="wrap_content" 
android:layout_gravity="center" 
android:layout_height="wrap_content"> 
    <TextView 
     android:id="@+id/textView" 
     android:layout_centerHorizontal="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello" /> 
    <ImageView 
     android:layout_below="@+id/textView" 
     android:id="@+id/image" 
     android:layout_centerHorizontal="true" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:src="@drawable/circle_place"/> 
    <TextView 
     android:id="@+id/textView2" 
     android:layout_centerHorizontal="true" 
     android:layout_below="@+id/image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="&lt;Username>" /> 
</RelativeLayout> 
</LinearLayout> 
</RelativeLayout> 
0

Использование ниже макете

<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" 
    tools:context="com.example.balazs_gerendai.intentopener.MainActivity" > 

    <ImageView 
     android:id="@+id/img_circle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:minHeight="250dp" 
     android:minWidth="250dp" 
     android:src="@drawable/circle" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:src="@drawable/circle_placeholder" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/imageView1" 
     android:layout_alignLeft="@+id/imageView1" 
     android:layout_alignRight="@+id/imageView1" 
     android:layout_marginBottom="10dp" 
     android:gravity="center_horizontal" 
     android:text="Hello" 
     /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/imageView1" 
     android:layout_alignLeft="@+id/imageView1" 
     android:layout_alignRight="@+id/imageView1" 
     android:layout_marginTop="10dp" 
     android:gravity="center_horizontal" 
     android:text="&lt;Username>"/> 

</RelativeLayout>