Set footer colour in xml - android

I am using the ViewPageIndicator library in my app. I know I can change the footer colour by using something like .setFooterColor(Color.Red) in my code. My question was if I can set this in xml instead as I would like to to all the styling in xml.
Below is the xml code
<com.viewpagerindicator.TitlePageIndicator
android:id="#+id/indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
What attribute do I need to set here to change the footer color? Thanks.

Here is an example for doing that:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/tn.mkh.example.android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/fragmentContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone" />
<com.viewpagerindicator.TitlePageIndicator
android:id="#+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:footerColor="#848484"
app:selectedBold="true"
app:selectedColor="#color/vpi_color_custom" />
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Good luck

Related

Can I overlap the WebView with an ImageButton?

What I want to create should look like this :
I want it like this because I want the button to cover a part of the content of the webview making it unreachable for the user.
You can do it using FrameLayout as follows...
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Button" />
</FrameLayout>
Yes You can do.for that purpose you have to use relative layout.first you have add webview,then add image button and set gravity bottom to image button.i think this can help you.
<?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:orientation="vertical" >
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#android:color/darker_gray"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>

How to show other views after list view height set to fill_parent

To prevent multiple GetView calling I have set the height of ListView to fill_parent.
How to show other views than the ListView itself?
The following layout is inflated in a ViewPager:
<?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"
android:padding="15dp" >
<ListView android:id="#+id/lv_viol_infraction"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<include layout="#layout/activity_prontuario_home" />
</LinearLayout>
where the included layout is:
<?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:padding="20dp" >
<ScrollView
android:id="#+id/prontuariohome_scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
.
.
.
.
</ScrollView>
</LinearLayout>
EDIT: This solution won't work for view higher than a button
I don't understand what you want to achieve, but if you NEED to have the height as fill_parent for some reason and can't be any other value, you can put the ListView with inside a LinearLayout with the height="0dp" and weight="1". So would be something like this:
<?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"
android:padding="15dp" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ListView android:id="#+id/lv_viol_infraction"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<include layout="#layout/activity_prontuario_home" />
</LinearLayout>
Try to use following code
android:layout_height="0dp"
android:layout_weight="1"
in ListView tag
With android:layout_height="0dip" the view will take the rest of the free place
You said this solution is wont work:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#+id/lv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white" android:layout_above="#+id/bt"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bt" android:layout_alignParentBottom="true"/>
just add it a android:layout_above="#+id/bt" to listview.
I'm sorry for being not clear.
Here is the link of the (probably) main thread asked here in Sof about the issue I was talking about.
After some tries I'm happy to give you the solution of my problem.
Giving another layout above the ListView lets the LV cuts the space not filled by the ListView itself
<?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"
android:padding="15dp" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView android:id="#+id/lv_viol_infraction"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<include layout="#layout/activity_prontuario_home" />
</LinearLayout>

Is there any way to change the width of TabPageIndicator (by Jake Wharton)?

I am using Jake Wharton's viewpager indicator and I would like to chage the width of it to a specific value. The common xml file as it can be found in the sample is:
<?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/background" >
<com.viewpagerindicator.TabPageIndicator
android:id="#+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
The width of the TabPageIndicator is fill_parent now, when I change it to a specific value, the whole things starts to behave weird and not well. I want to put an image in the same row where the TabPageindicator is located, but I do not want that to be the part of it. Is this possible?
Why don't you put it inside a LinearLayout with padding?
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<com.viewpagerindicator.TabPageIndicator
android:id="#+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

Aligning ViewPager and TextView Vertically

<?xml version="1.0" encoding="utf-8"?>
<!-- Layout-Normal-Portrait -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/thumb_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_above="#id/sum_layout"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
<RelativeLayout
android:id="#+id/sum_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#id/thumb_layout" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="#string/lorem__ipsum"
android:textColor="#color/black" />
</RelativeLayout>
</RelativeLayout>
As soon as I run the program, it shows a error in the editor saying "error: Error: No resource found that matches the given name (at 'layout_above' with value '#id/sum_layout')." which is at line 22 in this code.
Can any one tell, what is wrong?
I wonder why you are making it so complex.
Anyways here is corrected snippet
<?xml version="1.0" encoding="utf-8"?>
<!-- Layout-Normal-Portrait -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" > <---No need to specify android:orientation
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/textView" />
<TextView
android:id="#+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="6dp"
android:text="Hello"
android:textColor="#android:color/black" /> <---Place your text String here
</RelativeLayout>
use #+id/sum_layout
and clean Project and run again!
This is because you declare sum_layout id AFTER its first reference.
The best solution is to declare it in the /res/values/ids.xml like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="sum_layout" />
</resources>
And then reference it in all your layouts without the + keyword
<android.support.v4.view.ViewPager
android:layout_above="#id/sum_layout"
/>
And
<RelativeLayout android:id="#id/sum_layout" />
Try This
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:textColor="#color/black" />
When you are using relative layout, you are relating the controls with each other.when you add any control you add next control with respect to the control defined before.Likewise here you have defined view pager layout which is under layout having id #+id/sum_layout. but you have defined layout #+id/sum_layout under view pager.so it doesn't get id #+id/sum_layout,so how it will set view pager under the text view.first of all add the view and then add to its under/above.Here is your mistake:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager
android:id="#+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp">
</android.support.v4.view.ViewPager>
<TextView
android:id="#+id/mytext"
android:text="#string/lorem__ipsum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/mypager"/>
</RelativeLayout>
Set the layout according to this wherever you have to keep to its below or above.
hope it will help you.

android viewflipper not changing view : HELP ! :)

Im having trouble to make work the viewflipper. I created a xml layout file view_flipper.xml :
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="#+id/MainView" layout="#layout/gallery_1" />
<include android:id="#+id/SearchView" layout="#layout/search_internal" />
</ViewFlipper>
the layout gallery_1 is just a ListView.
the layout search_internal has an edittext, a button, and a listview.
Im using :
ViewFlipper theFlipper=(ViewFlipper) findViewById(R.id.flipper);
theFlipper.setDisplayedChild( R.id.SearchView );
to change the layout, but its apparently work for the code, but on the display, nothing is happening... Can someone help ?
Here is the code of the layout search_internal :
<?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="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/SearchBox"
>
<EditText android:text=""
android:id="#+id/QueryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="100px"
></EditText>
<Button android:layout_height="wrap_content"
android:id="#+id/BtnOk"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:text="#string/searchBtnTxt"
android:clickable="true"></Button>
</LinearLayout>
<ListView
android:id="#+id/list_view_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/SearchBox"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"
android:layout_marginBottom="65dip"
android:gravity="top"
/>
</RelativeLayout>
I've found that I was not using correctly the function setDisplayedChild. setDisplayedChild is zero based index apparently. Sorry.
theFlipper.setDisplayedChild( 0 );

Categories

Resources