i'm actually really new at coding in java and on AndroidStudio and i'm trying to update an application that already exist.
I have 3 LinearLayout that look like 3 square inside each other and inside the last one, i have a TewtView.
the first one is the main one and is always visible.
When i put my two last LinearLayout in visibility="GONE" my LinearLayout disapear, and i want that my textView will be always visible, even if the LinearLayout that contains it are invisible.
It is possible?
<LinearLayout
style="#style/ColPlayer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
style="#style/SquareBogey"
android:visibility="gone"
android:layout_width="70dp"
android:layout_height="50dp"
android:orientation="horizontal"
android:id="#+id/outersquare">
<LinearLayout
style="#style/SquareBogey"
android:visibility="gone"
android:layout_width="60dp"
android:layout_height="40dp"
android:orientation="horizontal"
android:id="#+id/innersquare">
<TextView
android:id="#+id/PlayerCJ01"
style="#style/ColCJPlayer"
android:layout_height="wrap_content"
android:ems="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Just ask me if you need more informations.
Thanks
When setting the visibility of a parent layout to GONE or INVISIBLE, all its children will also become GONE or INVISIBLE.
If you want to show the TextView but not its parent LinearLayout, than you could either move the TextView out of the LinearLayout, or you could remove the styling of the LinearLayout so it will look like its gone, but obviously it's still there.
Setting the visibility of the LinearLayout to GONE and its child TextView's visibility to VISIBLE won't work and therefore is not an option.
Instead of setting the visibility as GONE for the LinearLayouts, maybe you can set their background/border as transparent by changing their style.
It depends on your use case, if it suits your need.
Related
I am making an android app using Java in android studio. I have defined drawable background for listview with round edges. But last shown row is visually out of listview container. It is not just the line separating it from next record but also "-" symbol can be halfway out of the container. The app looks like this
is there a way to keep content inside the bounds?
It's happening bcz your background is different to listview and list view is always a square layout.
So basically, use cardview and set app:cardCornerRadius="" to cardview and list view set inside of cardview.
like this.
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="YOUR_BACKGROUND"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
OR
The other option is to use a round corner layout.
Git link
and set list view inside of any RoundCornerLayout.
I want to make a android activity screen where a layout is sticked to bottom until scrollview get scroll to a certain position. like in this video samples links:
https://drive.google.com/open?id=0B14wNBitoI33LWtUNThqcXRIUWc
https://drive.google.com/open?id=0B14wNBitoI33QW1BOGR1di1TcGc
amarjain07's StickyScrollView maybe a solution you would want to look into. His methodology of assigning the "sticky" views as identified attributes in the layout xml is quite a nifty feature IMHO.
Use a RelativeLayout and put the Button-Container inside it.
Pass the container in your_scrollview_activity.xml the following attribute
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1 (reft)" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 2 (right)"/>
</LinearLayout>
</RelativeLayout>
NOTE: You need to set a listener in your activity to get the ScrollViews current position / current height. With this current height you can calculate the "left space" to the bottom / end of the ScrollView. If your RelativeLayout reaches the bottom or if it's close to the bottom AND within the visible area, then call your animation.
Im searching a way how to fix a TextView on a ,for example, transparent square like in the Picture I did in Paint.net .So the TextView should in front of the transparent square (ImageView).Also it should stretch when the screen is bigger.
http://www7.pic-upload.de/22.02.14/24vtze5ulxc2.png
How can I solve the problem ?
Thanks !
Use a FrameLayout
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/semi_transparent_background"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="This is my text."/>
</FrameLayout>
Alternatively, you could do something similar with a relative layout.
You can use RelativeLayout or FrameLayout for that.
<FrameLayout>
<ImageView>
<TextView>
</FrameLayout>
Your textview will appear on ImageView.
Although note that, RelativeLayout has double taxation tradeoff. Each measure and layout happens twice.
Simply ordering the items in RelativeLayout from top to bottom in the XML will make each in turn move to the front compared to the others above it.
I have a FrameLayout which is a wrapper for a TextView. The TextView can be either one of two TextView objects with dynamically modified text. I would like to add an image immediately to the right of the text contained in the FrameLayout. I have tried two things:
I set up the FrameLayout inside a RelativeLayout. I added an ImageView:
<RelativeLayout>
<!-- Two TextViews Here -->
<FrameLayout
android:id="#+id/my_frame_layout"
android:layout_width="match_parent"
...
/>
<ImageView
android:id="#+id/my_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/my_frame_layout"
/>
</RelativeLayout>
This worked the first time the layout was loaded. However, when the text contained in the FrameLayout changed, the image stayed at its originally calculated position, rather than recalculating to stay to the right of the TextView.
So I tried making it a drawable and setting it in code. I fetched the TextView held in the FrameLayout, and called:
setCompoundDrawablesWithIntrinsicBounds(0,0,myDrawable,0)
This worked well, except that the drawable is always to the furthest right point of the FrameLayout, despite the TextView being only half full. I want the image to be immediately to the right of the text.
Does anyone have any other suggestions I could try to make this happen?
I ended up wrapping the ImageView in an additional LinearLayout, like so:
<LinearLayout
android:id="#+id/my_image_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="my_frame_layout"
android:gravity="left|center_vertical"
>
<ImageView
android:id="#+id/my_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Unlike the ImageView alone, the LinearLayout is redrawn when the text changes size, so this worked for me.
Just as the title says...I want to include a MapView inside of another activity. For instance, I want the MapView to take up half of the screen, and below that, include some other widgets - text fields, buttons, whatever. I have been tinkering with it, but so far I have been unsuccessful - the map does take up only half the screen, but no widgets show up.
Any clues? Is this possible, or is the Google Map integration strictly using the map as a full screen?
Please post your xml layout!
You are just doing it wrong. :-D
A mapview will work like any other widget. I strongly believe there is a mistake in your layout.
This one will work for instance!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/h1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox
android:text="Satellite"
android:id="#+id/satellite"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<ImageView
android:id="#+id/image"
android:layout_width="75dip"
android:layout_height="75dip"
android:layout_marginRight="6dip"
android:src="#drawable/uoicon" />
</LinearLayout>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0zDdYFYf6Ir2W-NuiHPLAoFjsq0nmqRhPfzjY3A"/>
</LinearLayout>
Just a guess but you're using a LinearLayout to contain the MapView and other widgets but you forgot to set the orientation to vertical? The default for LinearLayout is horizontal.
It came to mind because it's something I've done 2 or 3 times myself. Totally confusing as effectively the other widgets 'disappear' off the right-hand side of the screen. It eventually got engrained in my mind and I always make sure to explicitly specify orientation now when I use LinearLayout.