I am trying to implement scroll type gallery for my app.(Just like the full size image browser we get on default android gallery.)
What I am getting
instead I want the gallery image to be displayed on the entire screen.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical" >
<ImageView
android:id="#+id/left_arrow_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dip"
android:src="#drawable/arrow_left_disabled" />
<Gallery
android:id="#+id/gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_toLeftOf="#+id/right_arrow_imageview"
android:layout_toRightOf="#+id/left_arrow_imageview"
android:scaleType="fitXY"
android:spacing="20dip" />
<ImageView
android:id="#+id/right_arrow_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dip"
android:src="#drawable/arrow_right_enabled" />
</RelativeLayout>
Try to set the main relative layout to fill_parent and the ImageView to match_parent.
Related
I would like to have the possibility to set visible an image in the imageview (
that occupies half screen) while playing a video in a videoview. It's possible to do that?
Create a xml like this,
Add equal weight for the views and make there height 0dp, it will take equal height.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#ccc"
/>
<VideoView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
It will help you.
Thank u, I'm trying to do that in a Relative Layout like this, but the video is over the image when I change the image visibility... And I would like to have the opposite, and so the image over the video.
<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"
tools:context=".PatternSelection" >
<ImageView
android:id="#+id/settse"
android:layout_width="480dp"
android:layout_height="270dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:visibility="invisible"
app:srcCompat="#drawable/sett" />
<VideoView
android:id="#+id/videoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
I am working on a sample project and I am using the Universal Image Loader. UIL is great but I want to modify something, I just want to put buttons like Next / Previous in the Gallery.
But I can't see my Buttons view in the Gallery.
Here is the XML Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Gallery Demo"
android:id="#+id/txt"
/>
<Gallery
android:id="#+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:spacing="100px"
android:scrollbars="horizontal"
android:scrollbarFadeDuration="0"
android:scrollX="100px"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5px"
>
<Button
android:text="Previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnPrev"
android:onClick="onClick"
/>
<Button
android:text="Next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnNext"
android:onClick="onClick"
/>
</LinearLayout>
</LinearLayout>
It seems that the Gallery view is filling the whole space of the screen. Any ideas on how to do it?
Please check your ImagePagerAdapter extends BaseAdapter imageview android:layout_width and android:layout_height , It may be Fill_parent or wrap_content.
If it wrap_content then if you image is big then it show in full screen.
Thanks
like the title said it there are some "space" before and after an image and i don't want it.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/fond"
>
<ImageView
android:id="#+id/imageView1"
android:contentDescription="#string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/top"
android:layout_gravity="top"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/fond1"
>
</LinearLayout>
</LinearLayout>
So like you can see i have a first Layout with a background.
The ImageView is just after and should be on the top but it didn't.
The second Layout is to much after the image.
->
first layout
--unwanted space--
image
--unwanted space--
second layout
If anyone know how to delete this "space", thanks.
Use android:adjustViewBounds="true" inside your ImageView. That way your ImageView will be adjusted to the provided image bounds.
Use Relative layout this Way::
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/fond"
>
<ImageView
android:id="#+id/imageView1"
android:contentDescription="#string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/top"
android:layout_gravity="top"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:layout_below="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/fond1"
>
</LinearLayout>
</RelativeLayout>
I've got problem with my ListView item's background, it's bigger than should be.
Here is my background resource:
And it's screenshot from my device:
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bg_nocar">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:layout_marginLeft="6.67dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/reservation"
android:textStyle="bold"
style="#style/reservation_text" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/reservation.1"
style="#style/reservation_text" />
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/reservation.selectclass"
style="#style/reservation_selectclass_text"
android:layout_marginTop="33.33dp"
android:layout_marginLeft="6.67dp" />
<ListView
android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#00000000"
android:dividerHeight="0.67dp" />
</LinearLayout>
That's my item layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/reservation_row"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/car_bg"
android:orientation="horizontal">
<LinearLayout
android:layout_width="93.33dp"
android:layout_height="98.67dp"
android:orientation="vertical"
android:layout_marginLeft="6.67dp"
android:layout_marginTop="13.33dp">
<TextView
android:id="#+id/classname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="#style/reservation_classname" />
<TextView
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="#style/reservation_name"
android:layout_marginTop="16.67dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="98.67dp"
android:orientation="vertical"
android:layout_marginLeft="6.67dp"
android:layout_marginTop="13.33dp">
<ImageView
android:id="#+id/img"
android:layout_width="150dp"
android:layout_height="93.33dp"
android:layout_marginTop="6dp" />
<TextView
android:id="#+id/price"
android:layout_width="30dp"
android:layout_height="20dp"/>
<TextView
android:id="#+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
Why the background is so big?
Since you dont want your image to scale to the dimensions of the list item, you should not put it as a background.
Instead you can do this. Let the background be white (since your car_bg resource is all white with one logo). Then, your listview layout can look like this:
<RelativeLayout> //background white
<ImageView> //Your car_bg with width and height set as wrap_content
<LinearLayout> //All the content that you previously had
</RelativeLayout>
This way your image will not get scaled and remain as the original one. That said, you must now take car of different screen dimensions yourself. You must have different densitiy images available for your car_bg resource.
Try scaling the ImageView to keep its aspect ratio instead of attempting to set its height/width manually. This is most likely why your ImageView appears to be stretched.
I'm doing an Android gallery and I need to have the ImageView which shows a picture in full screen, and on top of it -meaning that it has to overlap the ImageView- the Gallery.
The problem is that now the ImageView occupies the portion that is not occupied by the Gallery, but I don't know how to achieve this.
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<ImageView
android:id="#+id/GalleryImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:scaleType="fitXY" />
<Gallery
android:id="#+id/GalleryThumbnails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/GalleryImage" />
</RelativeLayout>
Thanks a lot in advance!
You can use layout_alignTop=[Reference] to achieve that effekt.
Makes the top edge of this view match the top edge of the given
anchor view ID.
<ImageView
android:id="#+id/GalleryImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:scaleType="fitXY" />
<Gallery
android:id="#+id/GalleryThumbnails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/GalleryImage" />
Proof that it works