Хочу реализовать функциональность, которая есть в приложении Google Map под Android. Когда вы "кликаете" на поставленном маркере на карте снизу выдвигается панель с информацией.
В отличие от приложения, который написал Google мне не нужно после этого его "тянуть" что бы нижняя панель "развернулась" на весь экран. Данная панель должна быть фиксированной высоты. Данную проблему я решил.
Но теперь мне нужно закрепить на этой панели Floating Action Button. Как показано на рисунке ниже:
activity_main.xml:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
<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:background="@android:color/holo_orange_light"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/background_dark"
android:text="@string/hello_world" />
<FrameLayout
android:id="@+id/container"
android:layout_height="100dp"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
android:translationY="100dp"
</FrameLayout>
</RelativeLayout>
fragment1.xml:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Panel"
android:textColor="#0000DD"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:padding="5dp" />
</RelativeLayout>
Fragment1.java:
1.
2.
3.
4.
5.
6.
7.
public class Fragment1 extends Fragment {
public static final String TAG = "FRAGMENT1";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment1, container, false);
}
}
MainActivity.java:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
public class MainActivity extends AppCompatActivity {
private Fragment1 fragment1;
private FragmentManager fragmentManager;
private FragmentTransaction fragmentTransaction;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fragmentManager = getSupportFragmentManager();
fragment1 = new Fragment1();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
if (fragmentManager.findFragmentByTag(Fragment1.TAG) == null) {
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_bottom);
fragmentTransaction.add(R.id.container, fragment1, Fragment1.TAG);
fragmentTransaction.commit();
} else {
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_bottom);
fragmentTransaction.remove(fragment1);
fragmentTransaction.commit();
}
return true;
}
return super.onOptionsItemSelected(item);
}
}
Буду благодарен за любые идеи и решения. Приложение должно работать с версии 4.0.3.