I have a base activity and main activity but in main activity I have applied weightsum
but its not working properly. Below is the expected and current output
MainActivity.java
public class MainActivity extends BaseActivity {
LinearLayout dynamicContent,bottonNavBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dynamicContent = (LinearLayout) findViewById(R.id.dynamicContent);
bottonNavBar= (LinearLayout) findViewById(R.id.bottonNavBar);
View wizard = getLayoutInflater().inflate(R.layout.activity_main, null);
dynamicContent.addView(wizard);
}
}
Mainactivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="2"
android:layout_height="match_parent"
android:background="#F5F5F5"
tools:context="com.creativeframe.arun.pro.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/cbseschool"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/college"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
BaseActivity.java
public class BaseActivity extends AppCompatActivity {
RadioGroup radioGroup1;
RadioButton home,deals,account,settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base);
home = (RadioButton)findViewById(R.id.homebtn);
deals = (RadioButton)findViewById(R.id.dealsbtn);
account = (RadioButton)findViewById(R.id.accountbtn);
settings = (RadioButton)findViewById(R.id.settingbtn);
home.setCompoundDrawablesWithIntrinsicBounds( 0,R.mipmap.ic_home_white_24dp, 0,0);
deals.setCompoundDrawablesWithIntrinsicBounds( 0,R.mipmap.ic_navigation_white_24dp, 0,0);
account.setCompoundDrawablesWithIntrinsicBounds( 0,R.mipmap.ic_about, 0,0);
settings.setCompoundDrawablesWithIntrinsicBounds( 0,R.mipmap.ic_call_white_24dp, 0,0);
radioGroup1=(RadioGroup)findViewById(R.id.radioGroup1);
radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
switch (checkedId)
{
case R.id.homebtn:
home.setTextColor(Color.parseColor("#FF4081"));
startActivity(new Intent(getBaseContext(),MainActivity.class));
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
case R.id.dealsbtn:
deals.setTextColor(Color.parseColor("#FF4081"));
startActivity(new Intent(getBaseContext(), location.class));
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
case R.id.settingbtn:
settings.setTextColor(Color.parseColor("#FF4081"));
startActivity(new Intent(getBaseContext(), contact.class));
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
case R.id.accountbtn:
account.setTextColor(Color.parseColor("#FF4081"));
startActivity(new Intent(getBaseContext(), about.class));
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
default:
break;
}
}
});
}
}