Textview background - what's setting it? - android

I have the following layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/top_banner"
android:name="com.apps4care.mycarerecord.fragments.patientBannerFragment"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_alignParentTop="true"
tools:layout="#layout/patient_banner" >
</fragment>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top_banner" >
<LinearLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
<fragment
android:id="#+id/footer"
android:name="com.apps4care.mycarerecord.fragments.footerFragment"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_alignParentBottom="true"
tools:layout="#layout/footer">
</fragment>
</RelativeLayout>
I then add a number of fragments into the that have the following layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/documentFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/tvsectionHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:text="Section Heading Text Goes Here"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge" />
<WebView
android:id="#+id/wvsectionHTML"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tvsectionHeading"
/>
</RelativeLayout>
This gives a screen that looks like
My question is in three parts :
1) Where did the background color come from on the TextView. It is not set in the XML layout file or the code.
2) Why is the background color on the TextView not consistent. The bars lower down the screen are lighter, especially in the horizontal centre of the screen.
3) The Scrollview content is meant to stop above the "footer" fragment but it does not, the bottom of the content on the Scrollview is hidden behind the "footer" fragment.

The background for the TextView comes from it's (default) style which is transparent.
what you are seeing is the default background of activity in the Holo light theme. you can change it by overriding it in your theme, or setting a background color to the relative layout in you main layout file

The TextView colour is consistent, but it the colour of your background page, the default colour, which has a glow towards the bottom (it is the page's default formatting). This happened to my application too. Try changing the background of your page and see if the issue is still there, it should go away.

Related

Android: Non-transparent text on transparent image

I need to put text on transparent image, but my text goes transparent too.
Update: I have an Activity background which is a picture, than I have LinearLayout with background as transparent picture, and in that Layout I need a TextView with text without transparency.
<LinearLayout
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"
android:background="#drawable/img_background"
android:fitsSystemWindows="true"
tools:context="team.com.ContactUsActivity">
>
<LinearLayout
android:id="#+id/linearLayoutContactUsData"
android:layout_width="match_parent"
android:layout_height="200dip"
android:background="#drawable/img_contact_us"
android:alpha="0.4"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#FFFFFF"
android:textSize="18dip"
android:text="Phone: 111-111-111"
/>
</LinearLayout>
Any suggestions?
Just remove android:alpha.
If you don't, the TextView will inherit the container property, causing it to be transparent, instead of fully visible.
TextView backgrounds are transparent by default.

last button in layout doesn't have elevation

I'm working with Android Lollipop.
I have this layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/buttonlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/spacing_normal"
android:orientation="vertical" >
<Button
android:id="#+id/facebook_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/FacebookButton" />
<com.myCompany.views.widgets.CustomTextView
android:id="#+id/or_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/spacing_normal"
android:layout_marginBottom="#dimen/spacing_normal"
android:text="#string/app.widget.connexion.or"
app:font_name="Roboto-Medium.ttf" />
<Button
android:id="#+id/myCompany_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/myCompanyButton" />
the two style applied to the buttons are simply ripple effect with different background colors. The thing is the first button has an elevation with a shadow when we click it and the second hasn't unless I add an other widget below him. I suppose it's due to the ripple effect and because I had to change the background attribute, but I don't know how to make the effect back.
I tried to use translationZ and elevation attribute, but it didn't work (or I failed to use them properly).
any ideas ?

Softkeyboard hides elements of my layout that I want to be visibles

I've got a layout that looks like first image and when I open the softkeyboard looks like the second image, but I want it how it seems on third image:
I read a lot about adjustpan and adjustresize on the manifest but nothing works, the xml structure is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blanco"
android:gravity="top"
android:orientation="vertical"
android:weightSum="10" >
<!-- LOGO -->
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.7"
android:background="#color/green_logo"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="65dp" >
<ImageView
android:id="#+id/logo_registro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/logo_registro" />
</LinearLayout>
<FrameLayout
android:id="#+id/contentFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6.3" >
</FrameLayout>
</LinearLayout>
First part is the green part with the app logo and inside the FrameLayout I put Fragments that contains simple LinearLayouts or RelativeLayouts with parts of my Login forms.
Put this on your Manifest, inside the activity
<activity android:name=".YourActivity"
android:configChanges="keyboard|keyboardHidden"></activity>
Set your windowSoftInputMode in your manifest for this activity to be adjustResize. THere are 3 possible settings for this- nothing, resize (shrinks your app to fit the remaining space), and pan (scrolls your app so the focused field remains on screen).
Just Add the empty scrollview and it will work
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>

How can i set an image to be in the bottom left corner of an activity AND in the background

I want to set the logo of my app to the bottom left hand side of the screen and be in the background. the reason i want to do this is to allow the users to modify the background colors which would not be possible if i simply set the entire activity or layout background to an image to give same impression.
Another way of asking this is how do i set an image to bottom left hand corner and below other controls?
i don't know if i understand correct. but what you ask is pretty simple.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbbbbb"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="bottom|left"
android:layout_margin="10dp"
android:src="#ffff00" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<!-- Put your views here -->
</LinearLayout>
</FrameLayout>
you can change the frame layout's background as you wish and keep logo on bottom left corner.
Also you can set your LinearLayout (which you can use any layout. it is up to you) background to transparent so you will see background. and any extra view inside the linear layout (your view container) will be on top always.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/your_desired_full_background">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher_logo"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>

Scroll view shifting down on enabling navigation bar in Android

I am using fragments to display an image using ImageView, and ScrollView below the image view having some text using TextView in a RelativeLayout. Now the problem is that as seen in the image here there's a space created between the image and the scroll view when ever the navigation bar is enabled.
By enabling show layout bounds in the developer options, it's the image view creating the white space as seen here. There's no such space when viewed in the graphical layout on Eclipse.
Here's my xml of the fragment
<?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" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:src="#drawable/city_image" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:clipToPadding="false"
android:fitsSystemWindows="true" >
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:padding="16dp"
android:text="#string/fragment_main" />
</ScrollView>
</RelativeLayout>
I am new to Android and I apologize if I am making a silly mistake. I have tried to change scroll view's gravity to top and also played with layout_height. But still can't figure out what is wrong in my xml.

Categories

Resources