小编Nea*_*hal的帖子

如何正确设置高程值到recyclerview?

我正在使用android中的recyclelerview进行网格布局.网格占据屏幕的一部分并具有阴影.为了获得所需的阴影效果,我使用的是12 dp的高程值.但它似乎不起作用,因为我看不到网格的任何高程(阴影).为什么会这样?recyclerview不支持提升吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/activity_grid_layout"
android:background="@drawable/gradient"
android:layout_height="match_parent"
tools:context="com.mindhive.mindhive.activities.GridActivity">

<android.support.v7.widget.RecyclerView
    android:id="@+id/grid_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="110dp"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="80dp"
    android:background="@color/transparent"
    android:elevation="12dp"
    android:scrollIndicators="none"
    android:scrollbars="none"
    android:padding="0dp" />

<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/grid_recycler_view"
    android:layout_alignStart="@+id/grid_recycler_view"
    android:layout_marginBottom="-18dp"
    android:layout_marginStart="67dp"
    android:src="@drawable/main_filter"
    android:elevation="1dp" />
 ......
Run Code Online (Sandbox Code Playgroud)

android recycler-adapter android-recyclerview recyclerview-layout

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

应用程序被杀死时Geofences无法正常工作

我知道以前曾问过类似的问题,但答案并不完美.

我使用Android开发者网站的示例代码创建了一个使用地理围栏的应用程序.我没有使用任何共享首选项来存储地理围栏,因为我没有删除地理围栏.我正在地理围栏中测试应用程序,但我的智能手机每次应用程序运行时都会收到通知,并且在应用程序被杀死时没有观察到任何通知.为什么会这样?我想即使应用程序被杀,我也应该收到通知.

主要活动

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_layout);
    .....
GeofencingTask myTask = new GeofencingTask();
    myTask.execute();
}
private class GeofencingTask extends AsyncTask<String,Void,String> implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {

    @Override
    protected void onPreExecute() {


    }


    @Override
    protected String doInBackground(String... params) {


        mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();

        mGoogleApiClient.connect();
        mGeofenceList = new ArrayList<Geofence>();

        mGeofenceList.add(new Geofence.Builder()
                .setRequestId("1")

                .setCircularRegion(
                        Constants.MyAPP_LOCATION_LATITUDE,
                        Constants.MyAPP_LOCATION_LONGITUDE,
                        Constants.MyAPP_RADIUS
                )
                .setExpirationDuration(Constants.GEOFENCE_EXPIRATION_TIME)
                .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER |
                        Geofence.GEOFENCE_TRANSITION_EXIT)
                .build());
        return null;

    }

    protected void onPostExecute(String s) { …
Run Code Online (Sandbox Code Playgroud)

android android-location geofencing android-geofence

10
推荐指数
1
解决办法
4410
查看次数

印地语文本在android中无法正确呈现

我正在开发一个应用程序,我必须显示从服务器响应中收到的文本textview.文字可能在English or Hindi.在印地文的情况下,一些字母被问号代替(?).这是什么问题?这就是我设置文本的方式.Android version 6.字体类型 - Proxima Nova Alt Regular

 for (int i = 0; i < 3; i++) {
 viewHolder.lines[i].setText(poem.lines[i].lineText);
 }
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

unicode android utf-8 iso-8859-1 character-encoding

7
推荐指数
1
解决办法
1119
查看次数

在调用notifydatasetchanged后,Recyclerview滚动到顶部

我有一个水平的recyclerview(使用LinearLayoutManager),它的子项目有一个包含在relativelayout中的imageview.recyclerview有三个包含子项的水平行.当滚动recyclelerview时,我正在使用http调用的响应更新数据集,并在http响应回调中调用notifydatasetChanged.如果recyclerview子项的高度和宽度是固定值(例如150dp,84dp),则recyclerview的行为与预期相同,即加载新项并保持在相同的滚动位置,但如果我将recyclerview的子项的高度和宽度设置为match_parent, wrap_content,recyclerview完全刷新并滚动到第一个位置.为什么会这样?注意:我在SO上检查了其他类似的问题,但没有一个提供可行的解决方案.

main_layout

<android.support.v7.widget.RecyclerView
    android:id="@+id/grid_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="110dp"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="80dp"
    android:background="@color/transparent"
    android:outlineProvider="bounds"
    android:elevation="8dp"
    android:padding="0dp"
    android:scrollbars="none" />
....
Run Code Online (Sandbox Code Playgroud)

recycler_view_child_item

<RelativeLayout      xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="0dp">
<ImageView
    android:id="@+id/thumbnail"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:maxWidth="126dp"
    android:maxHeight="225dp"
    android:padding="0dp"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-activity android-recyclerview

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

Android中的HLS自适应流媒体仅在10秒后改变流?

我开发了一个小应用程序,可以录制和播放小视频(最多10秒).该应用程序以6 Mbps的速度捕获视频.为了确保更快的视频播放,我正在尝试实现HLS(http直播).但我注意到应用程序始终首先以最低比特率获取流,并且仅在10秒后才切换到最佳可用流(基于网络带宽).

我测试了不同的媒体播放器,如android媒体播放器,exoplayer等,但行为是一致的.视频仅在10秒后才会更改流.这是android中hls的默认实现吗?还是我错过了什么?我以前测试的m3u8是http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

        localUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
        vidView.setVideoPath(localUrl);
        Log.i("GenericRequest", "VideoUrl " + localUrl);
        vidView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
             vidView.start();
            }
        });
Run Code Online (Sandbox Code Playgroud)

video-streaming http-live-streaming android-mediaplayer android-videoview exoplayer

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