小编alb*_*alb的帖子

无法隐藏底部表,Android

我的有问题,因为当我打开活动时它会打开,阻止视图 在此输入图像描述

我认为,这种情况会发生,因为XML属性声明的高度为350dp:

<android.support.v4.widget.NestedScrollView
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="350dp"
    android:background="?android:attr/windowBackground"
    android:clipToPadding="true"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
Run Code Online (Sandbox Code Playgroud)

问题是,我无法将该值更改为0dp,因为下次当我尝试打开,没有,因为高度为0dp,所以它不会显示任何内容.我的问题是,有没有办法宣布关闭?(我尝试将stateState设置为STATE_COLLAPSED但不起作用).Bellow是与底部工作表交互的java代码.JAVA:

View bottomSheet = findViewById( R.id.bottom_sheet );
        mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public void onStateChanged(View bottomSheet, int newState) {
                if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
                    //mBottomSheetBehavior.setPeekHeight(0);
                    //mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                    //mBottomSheetBehavior.isHideable();
                }
            }

            @Override
            public void onSlide(View bottomSheet, float slideOffset) {

            }
        });
Run Code Online (Sandbox Code Playgroud)

java android bottom-sheet

6
推荐指数
2
解决办法
7634
查看次数

将相机移动到地图视图上的某个位置

我的联系人活动中有一个小地图视图: 图像

但我不知道如何将相机移动到特定位置,我之前在 MapActivity 上做过,但不知道如何在这里做。我不知道在哪里使用 moveCamera 函数,因为没有像 MapActivity 中那样的 onMapReady,感谢任何帮助人员。代码:

爪哇:

public class Contacts extends AppCompatActivity {
private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contacts);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Contactos");
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
}
Run Code Online (Sandbox Code Playgroud)

XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat 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"
    tools:context="com.example.abili.agriexport2.Contacts">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="25dp"
        android:orientation="vertical"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="0dp">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.20">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textView7"
                    android:layout_width="match_parent"
                    android:layout_height="0dp" …
Run Code Online (Sandbox Code Playgroud)

android google-maps

3
推荐指数
1
解决办法
9383
查看次数

Google Maps Utils如何解码列表中的折线值?

我正在使用谷歌地图方向Api和谷歌地图实用程序库绘制我的位置与标记之间的路径,我正在从方向Api 检索字段,但绘制的折线不正确所以现在我我正在尝试逐步构建折线,但我遇到了一个问题,我能够将所有折线添加到arraylist但是现在我如何从arraylist中检索它们来解码并构建它们;

这是JSON:

{
geocoded_waypoints: [
{},
{}
],
routes: [
{
bounds: {},
copyrights: "Dados do mapa ©2017 Google, Inst. Geogr. Nacional",
legs: [
{
distance: {},
duration: {},
end_address: "14 Avenue Latécoère, 31700 Cornebarrieu, França",
end_location: {},
start_address: "R. Zeferino Brandão 9, 2005 Santarém, Portugal",
start_location: {},
steps: [
{
distance: {},
duration: {},
end_location: {},
html_instructions: "Siga para <b>noroeste</b> na <b>R. Zeferino Brandão</b> em direção a <b>Tv. de São Domingos</b>",
polyline: {
points: …
Run Code Online (Sandbox Code Playgroud)

java android google-maps directions google-polyline

2
推荐指数
1
解决办法
5387
查看次数