medyo/Dynamicbox

Adview and orientation problem

Swisyn opened this issue · 5 comments

Hey thank you so much for developing this awesome library.

I've problem with viewing the custom view on an another view chich contains an adview.

Here is my custom_view

<ImageView
    android:id="@+id/imageView"
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:layout_gravity="center_horizontal|center_vertical"
    android:layout_marginTop="50dp"
    android:contentDescription="@string/app_name"
    android:src="@drawable/empty_favorites" />

<TextView
    android:id="@+id/title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    android:gravity="center"
    android:text="Kartlarım listeniz boş"
    android:textSize="25sp" />

and this is the main view;

<ListView
    android:id="@+id/listKartlarim"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >
</ListView>

<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="@string/bannerid" />

the problem is custom view doesn't centralize itself. You can see the problem on image.

https://www.dropbox.com/s/afug9t7qu2mysq4/2014-06-24%2010.41.54.png

Thank you for help.

I get the same issue if i use LinearLayout, please switch it to RelativeLayout.
See the example i made for the custom view here:
https://github.com/medyo/dynamicbox/blob/master/DynamicBoxExample/src/main/res/layout/music_not_found.xml

The problem is actually from the imageview, in your custom view image's size is 256x256 but mine is 512x512 to support tablets and when i changed the width and height of imageview to 250dp that it doesn't fit the screen but If i don't change the width and height of imageview and just resize my image to 256x256 problem solves. Isn't there a solution for this situation?

Thank you.

I didn't get you right. Do you want to use 256dp on phones and 512dp on tablets ?

Copy your 256dp image inside drawable-hdpi folder and the 512dp version inside drawable-large folder (if it doesn't exist, create it).

More details : http://developer.android.com/guide/practices/screens_support.html

I was creating only one drawable for all. I got it now. Thank you so much for help 👍