Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Button
- android:id="@+id/BtnRating1"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:text="@string/Rating_1"
- android:drawableTop="@drawable/face_1"
- style="?android:attr/borderlessButtonStyle"
- android:background="?android:selectableItemBackground"
- android:gravity="center"
- android:onClick="OnRating_1" />
- View view = LayoutInflater.from(context).inflate(R.layout.button_view);
- Button button = (Button) view.findViewById(R.id.BtnRating1);
- Button myButton = new Button(this);
- myButton.setText("Push Me");
- LinearLayout ll = (LinearLayout)findViewById(R.id.BtnRating1);
- LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
- ll.addView(myButton, lp);
- Button btn = new Button(ActivityContext);
- RelativeLayout.LayoutParams btnparamLayoutParams = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.MATCH_PARENT, 90);
- btn.setGravity(Gravity.CENTER_VERTICAL);
- btnparamLayoutParams.height = adjustedDp;
- btn1paramLayoutParams.setMargins(0, 0, 0, 100);
- btn.setLayoutParams(btnparamLayoutParams);
- btn.setBackgroundColor(Color.WHITE);
- LinearLayout ll = (LinearLayout)findViewById(R.id.linID);
- ll.addView(btn)
- 1. create a table row layout with button and inflate it.
- 2. you can create button dynamically and add it in your table row see below code for creating buttons dynamically .
- TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
- Button button = new Button(this);
- params.weight = 1;
- params.gravity = Gravity.CENTER;
- tablerow.addView(button,params);
- here this is context of activity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement