I am new in android. I am making quiz app and I want to use navigation view to Show current score of player by changing color of textview of points. I am using navigation drawer activity and home fragment for running the quiz.
this is code of home fragment
binding = FragmentHomeBinding.inflate(inflater, container, false);
View root = binding.getRoot();
NavigationView navigationView = (NavigationView) root.findViewById(R.id.nav_header);
View headerView = navigationView.getHeaderView(0);
TextView tv1=(TextView)headerView.findViewById(R.id.textView1);
TextView tv2=(TextView)headerView.findViewById(R.id.textView2);
TextView tv3=(TextView)headerView.findViewById(R.id.textView3);
TextView tv4=(TextView)headerView.findViewById(R.id.textView4);
TextView tv5=(TextView)headerView.findViewById(R.id.textView5);
TextView tv6=(TextView)headerView.findViewById(R.id.textView6);
TextView tv7=(TextView)headerView.findViewById(R.id.textView7);
TextView tv8=(TextView)headerView.findViewById(R.id.textView8);
TextView tv9=(TextView)headerView.findViewById(R.id.textView9);
TextView tv10=(TextView)headerView.findViewById(R.id.textView10);
TextView tv11=(TextView)headerView.findViewById(R.id.textView11);
TextView tv12=(TextView)headerView.findViewById(R.id.textView12);
TextView tv13=(TextView)headerView.findViewById(R.id.textView13);
TextView tv14=(TextView)headerView.findViewById(R.id.textView14);
TextView tv15=(TextView)headerView.findViewById(R.id.textView15);
TextView tv16=(TextView)headerView.findViewById(R.id.textView16);
switch (correctCountScore+1){
case 16: tv16.setBackgroundColor(Color.rgb(128,255,128));
case 15: tv15.setBackgroundColor(Color.rgb(128,255,128));
case 14: tv14.setBackgroundColor(Color.rgb(128,255,128));
case 13: tv13.setBackgroundColor(Color.rgb(128,255,128));
case 12: tv12.setBackgroundColor(Color.rgb(128,255,128));
case 11: tv11.setBackgroundColor(Color.rgb(128,255,128));
case 10: tv10.setBackgroundColor(Color.rgb(128,255,128));
case 9: tv9.setBackgroundColor(Color.rgb(128,255,128));
case 8: tv8.setBackgroundColor(Color.rgb(128,255,128));
case 7: tv7.setBackgroundColor(Color.rgb(128,255,128));
case 6: tv6.setBackgroundColor(Color.rgb(128,255,128));
case 5: tv5.setBackgroundColor(Color.rgb(128,255,128));
case 4: tv4.setBackgroundColor(Color.rgb(128,255,128));
case 3: tv3.setBackgroundColor(Color.rgb(128,255,128));
case 2: tv2.setBackgroundColor(Color.rgb(128,255,128));
default: tv1.setBackgroundColor(Color.rgb(128,255,128));
}
Below is nav header xml file :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_height="match_parent"
android:background="#color/black"
android:id="#+id/nav_header">
<ImageView
android:id="#+id/ivAudiencePoll"
android:layout_width="170dp"
android:layout_height="70dp"
android:layout_marginStart="0dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="50dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="#+id/ivFiftyFifty"
android:layout_width="170dp"
android:layout_height="70dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="50dp"
android:layout_marginRight="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/ivAudiencePoll"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/ivChangeQuestion"
android:layout_width="170dp"
android:layout_height="70dp"
android:layout_marginStart="60dp"
android:layout_marginLeft="60dp"
app:layout_constraintEnd_toStartOf="#+id/ivAskTheExpert"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ivAudiencePoll" />
<ImageView
android:id="#+id/ivAskTheExpert"
android:layout_width="170dp"
android:layout_height="70dp"
android:layout_marginTop="120dp"
android:layout_marginEnd="0dp"
android:layout_marginRight="80dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="250dp"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textView16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="16 Points" />
<TextView
android:id="#+id/textView15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="15 Points" />
<TextView
android:id="#+id/textView14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="14 Points" />
<TextView
android:id="#+id/textView13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="13 Points" />
<TextView
android:id="#+id/textView12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="12 Points" />
<TextView
android:id="#+id/textView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="11 Points" />
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="10 Points" />
<TextView
android:id="#+id/textView9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 9 " />
<TextView
android:id="#+id/textView8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 8 Points" />
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 7 Points" />
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 6 Points" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 5 Points" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 4 Points" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 3 Points" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 2 Points" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text=" 1 Points" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
But I am getting these error
2022-01-08 15:20:55.033 687-687/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.viky.homequiztest, PID: 687
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.viky.homequiztest/com.viky.homequiztest.MainActivity}: android.view.InflateException: Binary XML file line #15: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #15: Binary XML file line #19: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View com.google.android.material.navigation.NavigationView.getHeaderView(int)' on a null object reference
at com.viky.homequiztest.ui.home.HomeFragment.onCreateView(HomeFragment.java:72)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2963)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:518)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:3065)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2988)
at androidx.fragment.app.FragmentStateManager.ensureInflatedView(FragmentStateManager.java:392)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:281)
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:140)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.viky.homequiztest.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:53)
at com.viky.homequiztest.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:47)
at com.viky.homequiztest.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Activity.performCreate(Activity.java:7014)
2022-01-08 15:20:55.036 687-687/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2734)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Related
I want to align text view as mentioned below in my android application
totally two lines
in first line one text view layout weight 2
in second line one text view layout weight 2
the third text view combining both lines and the layout weight 1 and text alignment center
anyone please help me to get fixed this in my android application
the xml layout
<LinearLayout
android:id="#+id/imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/itemName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:importantForAutofill="no"
android:padding="15dp"
android:fontFamily="#font/bold"
android:textSize="20sp"
android:textColor="#color/black"
android:textAlignment="center"
tools:ignore="Deprecated,TouchTargetSizeCheck,DuplicateSpeakableTextCheck"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/eancode"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:textAlignment="center"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/rate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:importantForAutofill="no"
android:selectAllOnFocus="true"
android:padding="25dp"
android:fontFamily="#font/bold"
android:textSize="40sp"
android:textAlignment="center"
android:textColor="#color/black"
tools:ignore="Deprecated,TouchTargetSizeCheck,SpeakableTextPresentCheck" />
</LinearLayout>
</LinearLayout>
thank you
I have to add tetxview and two buttons inside cardview in such way that,
the two buttons should be on single line and below textview.
also please check below code for reference
here is my code
<FrameLayout xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Caption"
android:id="#+id/textQuestion"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp" />
<Button
android:id="#+id/btnAnswer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Expalantion"
/>
<Button
android:id="#+id/btnVideo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="video"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
I am having LinearLayout inside scroll view. I want to set LinearLayout's top margin to 50dp programmatically using below code
convertView = inflater.inflate(R.layout.apps_detail_item, parent, false);
LinearLayout childLayout = (LinearLayout) convertView.findViewById(R.id.childLayout);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
params.setMargins(0, 50, 0, 0);
childLayout.setLayoutParams(params);
But when I'm trying to run this code, my app is getting crash. Here is the error logs:
AndroidRuntime: FATAL EXCEPTION: main
Process: com.don.offers, PID: 11452
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
at android.widget.FrameLayout.onMeasure(FrameLayout.java:437)
at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17555)
at se.emilsjolander.flipview.FlipView.measureChild(FlipView.java:252)
at se.emilsjolander.flipview.FlipView.measureChildren(FlipView.java:245)
at se.emilsjolander.flipview.FlipView.onMeasure(FlipView.java:228)
at android.view.View.measure(View.java:17555)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:17555)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17555)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
at android.view.View.measure(View.java:17555)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2027)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1185)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1391)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1073)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5903)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:773)
at android.view.Choreographer.doCallbacks(Choreographer.java:586)
at android.view.Choreographer.doFrame(Choreographer.java:556)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:759)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5268)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
Here is my xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_color"
android:orientation="vertical">
<ScrollView
android:id="#+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomBar"
android:scrollbars="none">
<LinearLayout
android:id="#+id/childLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/banner_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/default_image_300_200" />
<View
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#drawable/top_tint" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="#drawable/bottom_tint">
<!--<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="#drawable/ic_launcher"
app:border_color="#FFF"
app:border_overlay="true"
app:border_width="2dp" />-->
<ImageView
android:id="#+id/logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/headLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toLeftOf="#+id/dislike_btn"
android:layout_toRightOf="#+id/logo"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/ratingbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="10dp">
<LinearLayout
android:id="#+id/people_used_count_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/verified_date_txt_layout"
android:layout_weight=".4"
android:gravity="center_vertical">
<RatingBar
android:id="#+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="5"
android:rating="3.5" />
</LinearLayout>
<LinearLayout
android:id="#+id/verified_date_txt_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".6"
android:gravity="center_vertical|right">
<TextView
android:id="#+id/downloadAndEarn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:singleLine="true"
android:text="#string/download_use_earn_text"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/text_color_dark_gray"
android:textSize="#dimen/fourteen_sp_text_size" />
<TextView
android:id="#+id/downloadAndEarnValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:text="₹20"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/green"
android:textSize="#dimen/twentifour_sp_text_size"
android:textStyle="bold"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/price_discount_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/text_color_dark_gray"
android:textSize="#dimen/sixteen_sp_text_size" />
<TextView
android:id="#+id/appDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/text_color_dark_gray"
android:textSize="#dimen/fourteen_sp_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#color/divider_color" />
<LinearLayout
android:id="#+id/user_goals_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#drawable/button_background">
<TextView
android:id="#+id/installNow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/install_now_text"
android:textAppearance="#android:style/TextAppearance"
android:textColor="#color/white"
android:textSize="#dimen/sixteen_sp_text_size" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/app_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#33000000"
android:visibility="gone"
>
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:text="#string/please_wait"
/>-->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</RelativeLayout>
I solved it myself. Here is the code
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 50, 0, 0);
childLayout.setLayoutParams(params);
I want create custom ui notification and show it full screen. How can I do it.
<LinearLayout>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="#drawable/icon_image" />
<TextView
android:id="#+id/alarm_text"
style="#style/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:text="#string/in_progress" />
<RelativeLayout
android:id="#+id/sticky_header"
android:layout_width="match_parent"
android:layout_height="#dimen/eader_height"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:id="#+id/sticky_text"
style="#style/normal_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="#string/message" />
<TextView
android:id="#+id/button"
style="#style/white"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/msg_selector"
android:gravity="center"
android:text="#string/msg" />
</RelativeLayout>
</LinearLayout>
I know there are RemoteViews we could use, but I am not sure how to set it up to NotificationCompat.Builder
Also I need to take action(launch activity) when the user presses the button in id -> button
I want to add applications to the ad. But I fail I want to add about the position advertised. Codes are as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">
<TextView
android:id="#+id/tarih"
android:textColor="#04B038"
android:textSize="15dp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:layout_gravity="center_horizontal"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/olaylar_liste"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<ProgressBar
android:layout_gravity="center_vertical|center_horizontal"
android:id="#+id/progress_olaylar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
<LinearLayout
android:layout_gravity="bottom"
android:orientation="horizontal"
android:id="#+id/adLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"></LinearLayout>
</LinearLayout>
I want adview showing bottom on linearlayout. Adview # + id /adLayout will be displayed on the Layout
Please help me.
try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">
<TextView
android:id="#+id/tarih"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="Header"
android:textColor="#04B038"
android:textSize="15dp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/adLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#ff0000"
android:orientation="horizontal"></LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/adLayout"
android:layout_below="#+id/tarih">
<ListView
android:id="#+id/olaylar_liste"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<ProgressBar
android:id="#+id/progress_olaylar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
</FrameLayout>
</RelativeLayout>