Webview in a small window - android

Is it possible to make the webview stay as a small window, instead of get the full screen?

A WebView is a widget like any other. You control its size via the layout you put it in.

Of course... for example this will make a WebView appear next to a ListView:
<?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"
>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<WebView
android:id="#+id/browser"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
Taken from a Mark Murphy example. By the way, Mark Murphy is the commonguy who answer this question some seconds ago.

Related

Simple OK button on activity

I have listview component in my activity and I managed to add button below it using the layout xml file of the activity. But the problem is that when in landscape the button is not visible because the listview is very long.
So is there a way to add simple OK button to close current activity but to be visible in either landscape or portrait, modes?
I know this page listview-voggela but it is kind of complex to implement, and I am not an android expert. So I am searching for simple solution. thanks
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="#+id/okbutton"
android:text="#string/hello" android:layout_alignParentBottom="true" />
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="#+id/list"
android:layout_alignParentTop="true" android:layout_above="#id/okbutton" />
</RelativeLayout>

Sliding List View Layout Android

I am creating an application that contains a header with a button on the right that should slide a list view to left when I click on it(similar to the chat list in Facebook)
-->
When I was including this header without putting the list view in it, it was working properly. But now I am inserting this list view inside the .xml file of the header (because the header is always shown for the user and he can click on this list view button in any layout that is shown for him).
The problem that I want to include this header to all the other layouts without changing the way they looks and show this list each time he click on the button.
I searched and found a lot of answers but every solution was about making the same as I did in the previous screen shots in each page which is not an optimistic solution for multiple pages.
*I am working on API level 10 and want to find the solution without using Actionbar.
Tell me please if more information would be helpful, any help will be really appreciated.
Thanks in advance.
UPDATE my xml file :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/GeneralRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:id="#+id/rel_layout"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:background="#android:color/white" android:layout_alignParentRight="true">
<LinearLayout android:id="#+id/fake_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"></LinearLayout>
<ListView android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#android:color/background_dark"
></ListView>
</RelativeLayout>
<RelativeLayout android:id="#+id/rel_layout_second"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black">
<LinearLayout android:id="#+id/lin_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:orientation="vertical"
android:layout_centerHorizontal="true" android:layout_alignParentTop="true">
<Button android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="slide"
android:layout_gravity="right|center"></Button>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Try to create a RelativeLayout for the ListView with a android:visibility="gone" and all the other components in the same User Interface inside another RelativeLayout.
Then change its visibility upon the state of the menu if it's opened or closed.
Guess this should be a way to go:
<?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" android:clickable="false">
<LinearLayout
android:id="#+id/thisistopbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingLeft="3dp"/>
<include here listview etc../>
</LinearLayout>
you can also make the top bar general and include it in every screen. But the basic idea is like above xml, and put the button on the top bar.

How to draw image at center of Radio button

I was looking through the example posted in http://bakhtiyor.com/2009/10/iphonish-tabs/, actually here they have placed Radio button as replacement for Tabview.
But the problem is, i am unable to set the image to the centre. Its always getting aligned to left.
Here is the screenshot. I want my view should look like this but instead i want image to be in center.
This is how my layout XML file looks
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dip"/>
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="#+id/allcontacts"
android:gravity="center"
android:id="#+id/contactgroup">
<RadioButton android:id="#+id/allcontacts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:background="#drawable/button_radio"/>
<RadioButton
android:id="#+id/categories"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/button_radio"
android:orientation="vertical"
android:layout_gravity="center|right"/>
<RadioButton android:id="#+id/favourites"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_weight="1"
android:background="#drawable/button_radio"/>
</RadioGroup>
<TabWidget android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" android:visibility="gone" />
</LinearLayout>
</TabHost>
Please advice me
UPDATED image after using Default tab widget
Is it possible to customize like above radio button in default tabview.?
Not actiually making the image centered, but you could make it appear that way... You could modify the image to have blank space on the left and cut off immediately to the right of the image.
EDIT
I don't know if you've seen any of these, but you made me curious so I went looking and found several links that might be helpful towards your ultimate goal of tabs on the bottom:
Niko's Blog
SO Question Answer
Another SO Question Answer
Good Luck!
Edit 2
Ok, found it. You will have to extend a new class from RadioButton and override onDraw(), then create an attrs.xml file you need to put in res/values so the code can get at platform-defined
attributes.
Specific code here
you can define your own ImageButton which extends CompoundButton. See the RadioButton and CompoundButton's source to learn how to do it.

My included layout doesn't fill the whole space when I set the visibility with View.GONE

I don't know if it's the right way to do this but I hope you'll be able to help me.
I'm using a ListActivity to display content from RSS feed. While the content is loading I want to display a pending view. I'm using the EndlessAdapter from that website https://github.com/commonsguy/cwac-endless. It provides a way to display a pending view but the first time it loads data it's a tiny row in an empty list so it's not very sexy.
I'm actually trying to fix this up with this method :
A custom layout for my ListActivity where there is a pending view that I can hide or show for the first loading. The XML code of the layout is like this :
<?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" >
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"/>
<include
android:id="#+id/progressBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="#layout/loading_anim">
</include>
</LinearLayout>
The first time I load data I set the list visibility to gone with this line :
listView.setVisibility(View.GONE);
It's almost working but the included layout doesn't fill the entire screen and right know I don't know how to fix this in a proper way.
Hope someone will be able to help me, thank's!
UPDATE :
I tried to set the contentview with only the loading layout (see XML below) and I got the same result (see http://imageshack.us/photo/my-images/594/loadingwf.png/) :
this.setContentView(R.layout.loading_anim);
<?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:background="#FFFFFF"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:padding="5dp" >
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/loading" />
</LinearLayout>
So I'm wondering if maybe it's because of the tabs... Can anybody help me ? Thank's
UPDATE 2
I found a solution, it had nothing to do with the neverending adapter. See The content of my tabs doesn't fill the whole space
In your ListView, try this:
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"/>
What I did was set layout_height to wrap_content. Should fill your entire screen now.

Layout :How to get the bottom bar under listview

I hope can get the layout like this:
-----Search bar(EditTextview)---
-----Listview(Rows)--------
-----Bottom bar(Contain many buttons)---
Pls give many samples
Thanks very much
I paste my xml file here.Pls help me check it:
Here's a layout from one of my apps, should be enough to get you started:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="#+id/list_view"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_weight="0"
android:gravity="bottom">
<!-- Buttons go here -->
</LinearLayout>
</LinearLayout>
Search for layout_weight to get an idea of how it works.
within your linearlayout, use Relativelayout for each edittext,listview and footer.
in footer layout set android:orientation="horizontal" it works.

Categories

Resources