i'm trying to show gif files in web view and create a nine patch photo(as frame)around the web view.but always web view and it's frame gets fill parent width.but i need the frame exactly shows around gif file without any extra space,this is my code:
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="#drawable/frame_tir3"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/web1"/>
</FrameLayout>
and i tried very different codes but any doen't work.
Related
My app has a lot of views that are containers for fragments (which load an image and other views) and depend on an API to fetch images. To make the development of the design easier, I like to add a sample of that image in my xml. Right now, I'm adding a RelativeLayout with the FragmentContainer and a dummy ImageView using different visibility values for android:visibility and tools:visibility.
Is there a better way to show images just for preview purposes ? I'd like to have the preview Views not compiled in the release version.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:adjustViewBounds="true"
tools:src="#drawable/image"
tools:visibility="visible" />
<RelativeLayout
android:id="#+id/FragmentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
If I understood your problem correctly, you could do something like this:
instead of using dummy views, use
<include tools:layout="#layout/layout_preview" layout="#layout/layout_actual"/>
where layout_preview.xml is whatever you want to use only in the preview, and layout_actual.xml is what will be used in the app
in case you wanted to only add a view in the preview, but have no view at all in the app, you can use a layout_actual.xml with an empty merge tag
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"/>
if you don't want to include useless layout, you might want to create the dummy ones only for debug build type, it will show an error in the layout because layout_dummy will be missing but since it's tools attribute you should be able to compile and run
In the webview.xml, I only have a frame layout as a wrapper for the webView as the following,
<FrameLayout
android:id="#+id/scroll_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="#+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
As a little background of the webview, it's basically a mobile web page that displays pictures, and allows for horizontal scrolling(either swiping or clicking the 'next' button). Right now, I'm able to scroll to the next photo via swiping, but once I release my finger, the photo pops back to the original photo. Same thing is happening for clicking next, the screen displays half of the next photo before scrolling back to the previous photo.
I have absolutely no idea why this is happening as I've tried all options with playing with the horizontal scrolling attributes, but it still isn't working. Could anyone who has experienced this provide some insights. Please feel free to let me know what additional info you need.
try using linear layout rather than using frame layout as you have only one child that is webview for the parent layout.
this one works for me :
<?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">
<WebView
android:id="#+id/webview_content"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
I'm making an app that displays images from urls in a listview. I use a asynctask to get the image and place it into the imageviews. The way I currently have it is that an asynctask is called in the getview method. The do in background part gets the image from the url. The problem I'm having is when I scroll to an element in the listview, initially the wrong image is there but the correct image is quickly loaded. Why is this happening?
xml
<?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:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitStart"
android:src="#drawable/ic_launcher" />
</LinearLayout>
Make sure that you are setting your ImageView to null as soon as you declare it. It's hard to tell without knowing what the image is, but it's possible that the ListView is reusing old images. Reference below:
wrong images are displaying first and then correct images are displaying during scrolling of listview
I am creating a activity for mix text and image input.
Here is the xml for container.
<ScrollView
android:id="#+id/new_question_body_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/new_question_tag_container"
android:layout_above="#+id/oler_keyboard_accessory"
android:layout_alignLeft="#+id/new_question_tag_container"
android:layout_alignRight="#+id/new_question_tag_container"
android:scrollbars="none">
<LinearLayout
android:id="#+id/new_question_body_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/new_question_body_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:hint="Please edit your body here."
android:layout_marginBottom="5dp"/>
</LinearLayout>
</ScrollView>
After dynamically add three (not lag for two) imageViews, it become pretty lag when scrolling.
Even if I make maxHeight and Width for each individual 50dp, the lag still exist. Am I adding imageView in the wrong way or this is the memory limit?
Wouldn't be better to use a ListView with custom layout (for each row) instead of a mix of ScrollView and LinearLayout?
If you want to add tons of images (just like a gallery), you may think about using LRUCache or another algorithm (i.e. lazy loading).
Also, consider the image size you're tring to load into memory. Maybe a smaller size and 'click to zoom' of each item should be a better aproach/UX
I wish to create header and footer image in my media player. Now the media player is working fine for me.
If I click media player its display video thumbnails in center of the screen(layout).
If I click that thumbnails the video will play.
My doubt is how to create header and footer images from video thumbnails showing page.
Give me your suggestion please, I am new with android applications.
Element description;
a. Header image, a stretched background image. The location of this external image comes
from the application xml.
b. Footer image, a stretched background image. The location of this external image comes
from the application xml.
xml source:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/videoGrdVw"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
I think you should use LinearLayout for header and footer inside RelativeLayout. Set both LinearLayot's orientation to Horizontal. You can also use DroidDraw. I use it sometime whenever i stuck with android layouts.
My suggestion to you is to use RelativeLayout when laying down elements on your application page. Good starting point for this layout is in this page. Also, this layout allows you to do exactly what you want, using ALIGN_PARENT_TOP and ALIGN_PARENT_BOTTOM attributes for your images. One more advantage of this layout is that it will easily adjust to any screen size. On the other side, only disadvantage of this layout is that it can be sometimes tricky to fully understand it's behavior.