1

私は、画像の下のように設定したい:Android - 特定のレイアウトの中心点からイメージを設定する方法は?

enter image description here

のplsは私がこのレイアウトを解決するのに役立つ。..事前に感謝 。

+1

あなたのレイアウトのコードを投稿してください。 – AndroidHacker

+0

何をしようとしましたか?あなたのXMLコードを投稿してください – Manishika

+0

Recyclerビューでイメージの半分を整列させたいですか? – AndroidHacker

答えて

0

BASIC

CardViewはImageViewのより高い高さを有しています。 ImageViewの高度を に設定してください。

ここでは...

<?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: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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".activity.Splash" 
    tools:showIn="@layout/activity_splash" 
    > 


    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:cardUseCompatPadding="true" 
     android:elevation="5dp" 
     android:stateListAnimator="@anim/button_elevation" 
     android:id="@+id/one" 
     android:layout_marginLeft="@dimen/activity_horizontal_margin" 
     > 

     <RelativeLayout 
      android:orientation="vertical" android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:padding="@dimen/activity_horizontal_margin" 
      android:background="?attr/selectableItemBackground" 

      > 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="this is just for test" 
       /> 

      </RelativeLayout> 
    </android.support.v7.widget.CardView> 


     <ImageView 
      android:layout_marginRight="@dimen/activity_horizontal_margin" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/cross" 
      android:id="@+id/two" 
      android:layout_centerVertical="true" 
      android:elevation="10dp" 
      /> 

</RelativeLayout> 
</RelativeLayout> 

そして、スクリーンショットを行く....

enter image description here

+0

これは動作していないより最後の画像から標高を削除してください - @AndroidHacker –

+0

解決策はあなたのために働かなかった...非常に驚くべきことです。 – AndroidHacker

関連する問題