Bring view to front in Swift
You can only modify the zPosition
in the concept of a CALayer
. UIView
does not expose this functionality. It does however expose two methods; sendSubviewToBack:
and bringSubviewToFront:
. This would need to be called on the superview of the view you want to move, and would take the view you want to move as an argument.
Also note that if you simply set userInteractionEnabled = false
on the top view, it will pass touches down to the view below it. This saves messing around with the view's positions.
View bring to front doesnt work
/**
* Change the view's z order in the tree, so it's on top of other sibling
* views. This ordering change may affect layout, if the parent container
* uses an order-dependent layout scheme (e.g., LinearLayout). Prior
* to {@link android.os.Build.VERSION_CODES#KITKAT} this
* method should be followed by calls to {@link #requestLayout()} and
* {@link View#invalidate()} on the view's parent to force the parent to redraw
* with the new child ordering.
*
* @see ViewGroup#bringChildToFront(View)
*/
public void bringToFront() {
if (mParent != null) {
mParent.bringChildToFront(this);
}
}
according to this I was simply missing the line
((View)myView.getParent()).requestLayout();
and it worked!
How to bring a view to front without calling bringToFront()?
apparently I missed the android:clipChildren="false"
property in GridView. It solves my problem.
Bringing a subview to be in front of all other views
What if the ad provider's view is not added to self.view
but to something like [UIApplication sharedApplication].keyWindow
?
Try something like:
[[UIApplication sharedApplication].keyWindow addSubview:yourSubview]
or
[[UIApplication sharedApplication].keyWindow bringSubviewToFront:yourSubview]
How to take a view to the front and make other views stay behind it in android?
You can achieve this by creating a custom alert dialog and inflating a layout into it.
public class CvvHelpDialog extends Dialog {
public CvvHelpDialog(@NonNull Activity context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dialog_cvv_help);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
getWindow().setAttributes(lp);
}
}
For R.layout.dialog_cvv_help, you can design a layout as your requirement. You can display it by simply using the below lines of code.
CvvHelpDialog cvvDialog = new CvvHelpDialog(getActivity());
cvvDialog.show();
Bring view to front of image view - Android XML
Your Layout is wrong. Try This:
<RelativeLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="135dp"
android:id="@+id/headerImageView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" android:layout_alignParentLeft="true"
android:scaleType="centerCrop"
android:adjustViewBounds="false"
android:background="@drawable/header_image_test" />
<Button
android:layout_width="49dp"
android:layout_height="49dp"
android:layout_alignBottom="@id/headerImageView"
android:layout_alignRight="@id/headerImageView"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/star"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/headerImageView"
android:orientation="horizontal"
android:layout_marginTop="-30dp"
android:id="@+id/main_details_layout">
<TextView
android:id="@+id/waitTimeTextView"
android:layout_width="90dp"
android:layout_height="90dp"
android:text="@string/wait_time_default"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:gravity="center"
android:background="@drawable/color0"
android:textColor="#FFFFFF"
android:textSize="30dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:text="Attraction Name"
android:textSize="23dp"
android:layout_marginRight="8dp"
android:gravity="bottom"
android:lines="1"
android:id="@+id/attractionNameTextView"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Last Updated"
android:textSize="16dp"
android:layout_marginRight="8dp"
android:gravity="bottom"
android:id="@+id/updatedTextView"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Related Topics
Display Fb Profile Pic in Circular Image View in Application
Android Getorientation Azimuth Gets Polluted When Phone Is Tilted
Android Emulator Not Receiving Push Notifications
Android - Way to Appear Bordered Text on the Textview
Android - What Is the Meaning of Stableids
Align Top of Image to Top of Textview
How to Prevent Multiple Toast Overlaps
Get Last Inserted Value from SQLite Database Android
Android Mediaplayer/Videoview Error (1, -2147483648)
How to Parse the CSV File in Android Application
Android:Understanding Drawable Folder
Java.Lang.Illegalstateexception: the Specified Child Already Has a Parent
How to Store and Retrieve a Byte Array (Image Data) to and from a SQLite Database
Live Character Count for Edittext