Answer the question
In order to leave comments, you need to log in
How to get rid of overlapping fragments on each other?
Good afternoon. There is an android application that uses fragments. When testing on a device, the fragment is superimposed on itself.
This is the main_activity.xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/blow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:baselineAligned="false"
android:weightSum="1">
<fragment
android:id="@+id/blow"
android:name="com.example.ilnitskiy.keepcalm5_final.blow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/blow">
</fragment>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/blow"
android:weightSum="1"
android:visibility="visible">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/p"
android:layout_weight="0.09"
android:textSize="40sp"
android:visibility="visible">
</TextView>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="@string/stop"
android:id="@+id/button"
android:layout_gravity="right"
android:layout_weight="0.09"
android:onClick="onClick"
android:visibility="visible" />
</LinearLayout>
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Fragment frag = new blow();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.blow, frag);
ft.commit();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question