[Solved] How to create layout like in this image? [closed]

Not sure is this what you want. You may try. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal” android:gravity=”start” android:background=”@android:color/white” android:padding=”12dp”> <ImageView android:id=”@+id/image” android:layout_width=”80dp” android:layout_height=”70dp” android:layout_centerVertical=”true” android:layout_gravity=”left”/> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_toRightOf=”@+id/image” android:layout_centerVertical=”true” android:paddingLeft=”6dp” android:orientation=”vertical” android:layout_alignParentRight=”true” android:layout_alignParentEnd=”true”> <LinearLayout android:id=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView android:id=”@+id/name” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textSize=”18sp” android:text=”Depeche Mode” android:singleLine=”true” /> </LinearLayout> <LinearLayout android:id=”@+id/ll2″ android:layout_below=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView … Read more

[Solved] Android – add lines dynamically to layout

use LinearLayout with vertical orientation instead of TextView in xml. Create TextView in Java. each time you get the string from server create new TextView in java and add this into LinearLayout. Here is example code. LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear_layout_id); TextView tv = new TextView(this); tv.setText(“FirstText”); tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT)); linearLayout.addView(tv); 1 solved Android – add … Read more

[Solved] Is any possible preview or run that particular program only in eclipse? [closed]

I believe you are asking whether you could modify your code to run in Eclipse as opposed to emulating an Android system and running it on that. Well, yes, you could (probably) change your code so it runs ‘in Eclipse’, however why would you do that? Then you don’t know if it runs on Android … Read more

[Solved] Null object reference error when trying to open new activity on Android? [duplicate]

You need to initialize your button, you are calling OnClickListener on null reference LoginButton =(Button)findViewById(R.id.button_login); Before calling LoginButton.setOnClickListener() initilize your login button. 6 solved Null object reference error when trying to open new activity on Android? [duplicate]

[Solved] How to construct a button on runtime (Android) [closed]

you can create button from code. you can find all the alternative methods of setting attribute in the doc. for example Button button = new Button(this); button.setText(“hi”); button.setId(Id); button.setTextColor(Color.Red); button.setBackgroundResource(R.drawable.icon); buttonlayout.addView(button); 1 solved How to construct a button on runtime (Android) [closed]

[Solved] How to pass data from activity to class in android? [closed]

Create a class for your requirement as CustomView and define public method to pass integer value and use it there. As I have created setIntValue(). public class CustomView extends View { private int mIntValue; public CustomView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public CustomView(Context context, AttributeSet attrs) { this(context, attrs, 0); … Read more

[Solved] Make a similar layout like the one below

Use below layout as item of your RecyclerView <?xml version=”1.0″ encoding=”utf-8″?> <androidx.cardview.widget.CardView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”wrap_content” app:cardCornerRadius=”15dp” app:cardMaxElevation=”3dp” android:elevation=”3dp” app:cardUseCompatPadding=”true” app:cardBackgroundColor=”@android:color/white”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <LinearLayout android:layout_weight=”.95″ android:layout_width=”0dp” android:layout_height=”wrap_content” android:orientation=”vertical”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:padding=”15dp”> <TextView android:id=”@+id/tv_received_message_heading” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Received Message:”/> <TextView android:id=”@+id/tv_received_message” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”First Received Message” android:layout_marginStart=”5dp”/> </LinearLayout> <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”@color/colorPrimary” android:layout_marginStart=”10dp” … Read more

[Solved] How to set a click in center of RelativeLayout after load Activity

use gravity center in RelativeLayout and place clickable element in RelativeLayout <Button android:id=”@+id/the_button” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Centered Button”/> use android:layout_centerInParent=”true” in clickable element inside the RelativeLayout <Button android:id=”@+id/the_button” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Centered Button” android:layout_centerInParent=”true”/> 5 solved How to set a click in center of RelativeLayout after load Activity

[Solved] When should I use layout_centerHorizontal=true and gravity=”center_horizonatal” and foregroundGravity=”centerHorizontal”?

When you use RelativeLayout – You should use layout_centerHorizontal,layout_centerVertical,layout_centerInParent but when you use LinearLayout , you should use gravity to align children i.e., layout_gravity and gravity. foregroundGravity is used with foreground tag. What is in foreground it will align according to foregroundGravity solved When should I use layout_centerHorizontal=true and gravity=”center_horizonatal” and foregroundGravity=”centerHorizontal”?

[Solved] Android code without casting

Because if you want to assign a supertype to a specific subtype variable, you need to downcast it to the actual type. Much of the Android framework is from an era before Java generics was available. Is there some better way to approach this? If you only need the View from a findViewById() return, make … Read more