Stuck on this for a while and tried several different things.
I basically redefined the frame to create my own button. In the layout of the frame there are two children - a button and a linear output with elements in it.
The problem is that I am trying to get the button to stretch to the size of the frame layout (i.e. fill the parent element), and this is not done. Here is the code, just ask if you want more detail:
public class ReminderButton extends FrameLayout{ private TextView text; private ImageView video; private ImageView pdf; public Button button; private LinearLayout itemsLayout; public ReminderButton(Context context, AttributeSet attrs) { super(context, attrs); this.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); this.setFocusable(false); LinearLayout itemsLayout = new LinearLayout(context); itemsLayout.setOrientation(LinearLayout.HORIZONTAL); itemsLayout.setFocusable(false); itemsLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); itemsLayout.setWeightSum(100); LinearLayout textLayout = new LinearLayout(context); textLayout.setFocusable(false); textLayout.setLayoutParams(new LinearLayout.LayoutParams(0,LayoutParams.FILL_PARENT, 80)); textLayout.setGravity(Gravity.CENTER); text = new TextView(context); text.setFocusable(false); text.setTextColor(Color.WHITE); text.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); text.setPadding(5, 3, 3, 3); LinearLayout imagesLayout = new LinearLayout(context); imagesLayout.setOrientation(LinearLayout.VERTICAL); imagesLayout.setFocusable(false); imagesLayout.setLayoutParams(new LinearLayout.LayoutParams(0,LayoutParams.FILL_PARENT, 20)); imagesLayout.setGravity(Gravity.CENTER); video = new ImageView(context); video.setFocusable(false); video.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); video.setImageResource(R.drawable.ic_video_small); pdf = new ImageView(context); pdf.setFocusable(false); pdf.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); pdf.setImageResource(R.drawable.ic_pdf_small);
source share