Skip to content

Instantly share code, notes, and snippets.

@armanso
Last active October 5, 2023 21:20
Show Gist options
  • Save armanso/4c8023b3ee84751838469f5184f1f5dd to your computer and use it in GitHub Desktop.
Save armanso/4c8023b3ee84751838469f5184f1f5dd to your computer and use it in GitHub Desktop.
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import arman.so.shadowexample.R;
import arman.so.shadowexample.utils.ViewUtils;
/**
* Created by ArmanSo on 4/16/17.
*/
public class RoundLinerLayoutNormal extends LinearLayout {
public RoundLinerLayoutNormal(Context context) {
super(context);
initBackground();
}
public RoundLinerLayoutNormal(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initBackground();
}
public RoundLinerLayoutNormal(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initBackground();
}
private void initBackground() {
setBackground(ViewUtils.generateBackgroundWithShadow(this,R.color.white,
R.dimen.radius_corner,R.color.shadowColor,R.dimen.elevation, Gravity.BOTTOM));
}
}
@GeraldoLimaGlance
Copy link

Hey, nice solution! But it's ignoring the width and height values I'm setting in the child layout XML and changing the view's size to be really close to its content area. I tried to set the fixed size in the parent view, but the result is the same. Any thoughts?

<net.myapplication.RoundLinearLayoutNormal
        android:id="@+id/roundLinearLayoutBt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="24dp"
        android:layout_marginTop="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/roundLinearLayoutNormal">

        <ImageButton
            android:id="@+id/ibVideoState"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:background="@android:color/transparent"
            android:src="@drawable/glance_ic_visitor_video_disabled"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </net.myapplication.RoundLinearLayoutNormal>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment