在每个屏幕尺寸上将Textview放在ImageView上兼容

时间:2018-10-09 12:43:24

标签: android textview imageview

我有2个图像和4个textview,我想在当前工作的图像上放置textview。

我必须像2一样放置4个textview。有没有办法不用DP就可以做到这一点,因为如果分辨率改变时我使用DP看起来很糟糕。

我当前的工作是:

Current Work

我希望它看起来像这样:

I want to make it like that.

我的活动代码 t

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"

    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:background="@color/grey"
    tools:context=".MainActivity">


  <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="300dp">
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="horizontal">
         <android.support.constraint.ConstraintLayout
             android:layout_width="0dp"
             android:layout_weight="1"
             android:layout_height="match_parent">


          <ImageView
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:src="@drawable/solayak"
              />
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:text="Deneme"
                 android:gravity=  "center"

                 />
         </android.support.constraint.ConstraintLayout>

          <android.support.constraint.ConstraintLayout
              android:layout_width="0dp"
              android:layout_weight="1"
              android:layout_height="match_parent">

          <ImageView
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:src="@drawable/sagayak"
              />
          </android.support.constraint.ConstraintLayout>
      </LinearLayout>



  </LinearLayout>



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="center"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            app:srcCompat="@drawable/arti_buton_yeni" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            app:srcCompat="@drawable/eksibutton_yeni" />

    </LinearLayout>


    <include
        layout="@layout/bottomnavigation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>

0 个答案:

没有答案