2016-06-15 2 views
0

Так что я хочу использовать 2 изображения. Один должен быть сверху другого, но меньше, так что граница изображения, которая находится позади, отображается только. Взгляните на эти 2 фотографии.2 изображения друг на друга - XML ​​- Android

Изображение, которое находится позади (граница изображения) [IMG] http://i66.tinypic.com/25zgguh.jpg[/IMG]

Изображение, которое должно быть внутри границы [IMG] http://i67.tinypic.com/10mpgt4.jpg[/IMG]

XML КОД

<com.inthessaloniki.cityguide.view.SelectorRelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/fragment_poi_list_item" 
android:layout_width="match_parent" 
android:layout_height="@dimen/fragment_poi_list_recycler_item_size" 
android:minHeight="@dimen/fragment_poi_list_recycler_item_size" 
android:listSelector="@drawable/selector_clickable_item_bg_inverse"> 



<ImageView 
    android:id="@+id/fragment_poi_list_item_image" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/fragment_poi_list_recycler_item_size" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/fragment_poi_list_recycler_item_panel_height" 
    android:layout_alignParentBottom="true" 
    android:gravity="center_vertical" 
    android:orientation="vertical" 
    android:paddingLeft="@dimen/global_spacing_xs" 
    android:paddingRight="@dimen/global_spacing_xxs" 
    android:background="@color/fragment_poi_list_recycler_item_panel_bg"> 

    <TextView 
     android:id="@+id/fragment_poi_list_item_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="@style/TextAppearance.CityGuide.Body1.Inverse" 
     android:fontFamily="sans-serif" 
     android:maxLines="2" 
     android:ellipsize="end" /> 

    <TextView 
     android:id="@+id/fragment_poi_list_item_distance" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:drawableLeft="@drawable/ic_grid_distance" 
     android:drawablePadding="@dimen/fragment_poi_list_recycler_item_icon_padding" 
     android:textAppearance="@style/TextAppearance.CityGuide.Body1.Inverse" 
     android:fontFamily="sans-serif" 
     android:maxLines="1" 
     android:ellipsize="end" /> 

</LinearLayout> 

Я думал, могу ли добавить андроид: background = "First Image" и сделать мой центр просмотра изображений, но оставляя некоторое пространство на краях для фона, который будет показан.

Опубликовал еще 2 изображения, показывающие, как приложение и как оно должно выглядеть, но сайт не позволит мне отправлять более двух ссылок, потому что моя репутация ниже 10 -_- Заранее благодарим за Помогите!!!

ответ

0

Делают это так:

<com.inthessaloniki.cityguide.view.SelectorRelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/fragment_poi_list_item" 
android:layout_width="match_parent" 
android:layout_height="@dimen/fragment_poi_list_recycler_item_size" 
android:minHeight="@dimen/fragment_poi_list_recycler_item_size" 
android:listSelector="@drawable/selector_clickable_item_bg_inverse"> 


<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/background_image" 
    tools:context=".MainActivity"> 

    <ImageView 
     android:id="@+id/view" 
     android:layout_margin="5dp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/foreground_image" /> 

</RelativeLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/fragment_poi_list_recycler_item_panel_height" 
    android:layout_alignParentBottom="true" 
    android:gravity="center_vertical" 
    android:orientation="vertical" 
    android:paddingLeft="@dimen/global_spacing_xs" 
    android:paddingRight="@dimen/global_spacing_xxs" 
    android:background="@color/fragment_poi_list_recycler_item_panel_bg"> 

    <TextView 
     android:id="@+id/fragment_poi_list_item_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="@style/TextAppearance.CityGuide.Body1.Inverse" 
     android:fontFamily="sans-serif" 
     android:maxLines="2" 
     android:ellipsize="end" /> 

    <TextView 
     android:id="@+id/fragment_poi_list_item_distance" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:drawableLeft="@drawable/ic_grid_distance" 
     android:drawablePadding="@dimen/fragment_poi_list_recycler_item_icon_padding" 
     android:textAppearance="@style/TextAppearance.CityGuide.Body1.Inverse" 
     android:fontFamily="sans-serif" 
     android:maxLines="1" 
     android:ellipsize="end" /> 

</LinearLayout> 
+0

спасибо за ответ. Это действительно работа! :) – AresProductions

+0

Счастлив, что помогло вам .. :) –

0

надежды я получил ясно, вы могли бы просто использовать два макета и отрегулировать запас для маленькой. поместить изображения в качестве фона или RelativeLayout использования ImageView в макетах

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="25dp"></RelativeLayout> 
</RelativeLayout> 
+0

Ваш ответ был почти таким же и решил проблему тоже! Мне просто пришлось дать ответ тому, что было сделано ранее. Так что спасибо, что нашли время, чтобы помочь мне !!! – AresProductions

+0

Рад помочь, спасибо – Elgoph

Смежные вопросы