getHeight returns 0 for all Android UI objects

It’s 0 because in both onCreate and onStart, the view hasn’t actually been drawn yet. You can get around this by listening for when the view is actually drawn: final TextView tv = (TextView)findViewById(R.id.venueLabel); final ViewTreeObserver observer= tv.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { tv.getHeight() observer.removeGlobalOnLayoutListener(this); } }); The call to remove the … Read more

How to disable behind view click event Framelayout

A better way is to set the top and bottom frame to be clickable, with: android:clickable=”true” Doing so will make sure that the view/frame itself will trap all clicking events, and will not pass it through the view behind it. Note this method works for all layout/view/controls, but many controls (such as buttons) already have … Read more

Android center view in FrameLayout doesn’t work

We can align a view in center of the FrameLayout by setting the layout_gravity of the child view. In XML: android:layout_gravity=”center” In Java code: FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; Note: use FrameLayout.LayoutParams not the others existing LayoutParams

What does FrameLayout do?

You use a FrameLayout to stack child views on top of each other, with the most recent child on top of the stack. In the example below, the TextView is the most recent, so it is automatically placed on top of the ImageView. For example: <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <ImageView android:id=”@+id/backgroundImage” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:scaleType=”centerCrop” … Read more

Full screen background image in an activity

There are several ways you can do it. Option 1: Create different perfect images for different dpi and place them in related drawable folder. Then set android:background=”https://stackoverflow.com/questions/16135984/@drawable/your_image” Option 2: Add a single large image. Use FrameLayout. As a first child add an ImageView. Set the following in your ImageView. android:src=”https://stackoverflow.com/questions/16135984/@drawable/your_image” android:scaleType = “centerCrop”

What are the differences between LinearLayout, RelativeLayout, and AbsoluteLayout?

LinearLayout means you can align views one by one (vertically/ horizontally). RelativeLayout means based on relation of views from its parents and other views. ConstraintLayout is similar to a RelativeLayout in that it uses relations to position and size widgets, but has additional flexibility and is easier to use in the Layout Editor. WebView to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)