I want to make a layout like shown in images below. it's like googlemap and you can zoom in/out with multi finger touch, and also scrolling in four way. is there any library supporting this layout?
zoomed out image:
[http://i57.tinypic.com/2hoz6rl.png][1]
zoomed in and scrolled:
[http://i58.tinypic.com/zxnqqb.png][2]
.....
third pic in the comments
Use ScrollView element in your xml
<ScrollView
android:id="#+id/someId"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<HorizontalScrollView
android:id="#+id/horizontalSomeId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true" >
`enter code here`
</HorizontalScrollView>
</ScrollView>
Use TouchImageView.
Refers this link.
How can I get zoom functionality for images?
From here you can download TouchImageView class or Library.
https://github.com/MikeOrtiz/TouchImageView
https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java
If its works for you then give me a Check mark for correct answer.
Related
So, i wanted to put an image in background of my screen. My problem is that if i just add the image to "background" it will fill all the screen, and my image gets defaced. I could put as an ImageView, but the problem is that i have an expandableListView in the same screen, and i wanted the image to stay behind, as a background.
Any idea how to do this?
Can have 2 solutions: Put as an imagemView but behind the list. Or add as a background but resize it. How can i do it?
Here is what happened:
He is what happens if i put the image as an imageView:
Yes this is very easy to achieve with relative layouts
<RelativeLayout ... >
<ImageView ...
android:layout_alignParentTop="true"
android:scaleType="centerCrop“ />
<ListView ...
android:layout_alignParentTop="true“ />
</RelativeLayout>
With a relative layout z-index is decided by the order you declare the tags, so stuff towards the bottom of the xml is in front of stuff from closer to the top, when they are in the same position.
Use a FrameLayout (Inside FrameLayout view written on top will appear on top and so on)
<FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
></ListView>
<ImageView
android:layout_width="your_width_in_dp"
android:layout_height="your_height_in_dp"
/>
</FrameLayout>
You can also place FrameLayout inside another layout.
i want fill CardView with custom text and image such as listview, but i dont know :( Please see the sample picture to better understand what I mean
Simple Picture : simple picture link.
i use this link for CardView : CardView Link
I am an amateur, please give me the source code
You have pretty much all you need from the Android documentation. Just gonna give you a couple things that might not be obvious.
CardViewis a child of FrameLayout so you basically want to build a Frame Layout with text and and image. If you are not familiar with FrameLayout what you need to do is put a LinearLayout (or any other that you find appropriate) inside the FrameLayout (or the CardView for this case) and add your other widgets inside.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
... >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<--This is where you add the text and image-->
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Try that and if you get stuck we can always help, but don't let the fact that you are new to Android stop you from doing things yourself, don't just ask for the code without trying first or you will always be an amateur
I need a vertical scrollview similar as present in below image.
But I have Got scrollview as present in below picture
My code is
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical"
android:fadeScrollbars="false"
android:scrollbarThumbVertical="#drawable/scroll_bar_thumb"
android:scrollbarTrackVertical="#drawable/scroll_bar_track">
My problem is scroll_bar_thumb goes inside the scroll_bar_track. Give some solutions.
Thanks in advance.
Try looking here
Custom scrollbar Android
and maybe there
https://github.com/rno/Android-ScrollBarPanel
I want to place 2 ImageViews, one above the other.
Here is an example with a square and a circle.
How can I do that? I know only in runtime what images to use, so I cannot specify them in an xml file.
Thank you in advance.
You can use FrameLayout to stack views on each other.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/img_green" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/img_red"/>
</FrameLayout>
then you may set android:layout_margin="" to properly position the ImageViews.
Note that the last child of FrameLayout is the top most visible view
You should specify their location inside the layout programmatically, this is not exactly what you are asking for, but you will get an idea of what you have to do :
How to create a RelativeLayout programmatically with two buttons one on top of the other?
Since absolute layout is deprecated you probably have to play with margins.
I have an image that takes up a lot more space than the android screen. I want the image to be presented full size and the user can move in any direction. Like a map.
Any suggestions?
You can use a webview which gives this to you for free. I'm not sure why but when I tried
using the loadData method it didn't work, but using loadDataWithBaseURL with a null URL did.
With a webview your image can even be embedded in HTML. In the example below yourContent is simply a string.
E.g.
yourView.loadDataWithBaseURL(null, yourContent, "text/html", "UTF-8", null);
Here is a tutorial I saw that did what you are describing
http://www.anddev.org/scrolling_a_picture_horizontally_and_vertically-t3245.html
You can put your image in an ImageView and wrap it using a ScrollView and a HorizontalScrollView like below.
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/yourImage"/>
</ScrollView>
</HorizontalScrollView>
So you can scroll it horizontally and vertically like a map.
Try to put scroll into xml layout with your image