我有一个DialogFragment包含RecyclerView(卡片列表).
其中RecyclerView一个或多个CardViews可以具有任何高度.
我想DialogFragment根据CardViews其中包含的内容给出正确的高度.
通常情况下,这将是简单的,我会成立wrap_content的RecyclerView这个样子.
<android.support.v7.widget.RecyclerView ...
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:scrollbars="vertical" >
</android.support.v7.widget.RecyclerView>
Run Code Online (Sandbox Code Playgroud)
因为我使用的RecyclerView这个不起作用,请看:
https://issuetracker.google.com/issues/37001674
和
在这两个页面上,人们建议扩展LinearLayoutManager和覆盖onMeasure()
我首先使用了第一个链接中提供的LayoutManager:
public static class WrappingLayoutManager extends LinearLayoutManager {
public WrappingLayoutManager(Context context) {
super(context);
}
private int[] mMeasuredDimension = new int[2];
@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
int widthSpec, int heightSpec) {
final int widthMode = View.MeasureSpec.getMode(widthSpec);
final …Run Code Online (Sandbox Code Playgroud) android android-layout android-fragments android-studio android-recyclerview
如何在Android Studio 2.0 Preview中禁用Instant Run.当我进入设置时,我看到它:
我无法从"启用即时运行..."中删除勾号
我使用的是Android Studio 2.0 Preview 9,但Android Studio 2.0 Preview 7中也存在此错误.
settings android android-studio instant-run android-instant-run
我有一个应用程序来管理书籍集(如播放列表).
我想显示一个带有垂直RecyclerView的集合列表,并在每行内部显示一个水平RecyclerView中的书籍列表.
当我将内部水平RecyclerView的layout_height设置为300dp时,它会正确显示,但是当我将其设置为wrap_content时,它不会显示任何内容. 我需要使用wrap_content,因为我希望能够以编程方式更改布局管理器以在垂直和水平显示之间切换.

你知道我做错了什么吗?
我的片段布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<com.twibit.ui.view.CustomSwipeToRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/shelf_collection_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"/>
</LinearLayout>
</com.twibit.ui.view.CustomSwipeToRefreshLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
集合元素布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF">
<!-- Simple Header -->
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty_collection"
android:id="@+id/empty_collection_tv"
android:visibility="gone"
android:gravity="center"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/collection_book_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/> <!-- android:layout_height="300dp" -->
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
书目项目:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="220dp"
android:layout_gravity="center">
<ImageView
android:id="@+id/shelf_item_cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxWidth="150dp"
android:maxHeight="200dp"
android:src="@drawable/placeholder"
android:contentDescription="@string/cover"
android:adjustViewBounds="true"
android:background="@android:drawable/dialog_holo_light_frame"/> …Run Code Online (Sandbox Code Playgroud) android android-layout android-support-library android-studio android-recyclerview
我在Google Play上遇到过很多这样的问题,我使用的是Android 4.2.2 API 17.
我的应用需要Google Play服务8.1,它编译得很好,当它在模拟器上运行时会显示"您需要更新Google Play服务"的消息,
当我点击更新时没有任何反应,
如何在不下载任何最新API版本的情况下更新Google Play服务?
android android-emulator google-play google-play-services android-studio
是否有一个函数来获取文件路径的目录部分?
所以
String a="/root/sdcard/Pictures/img0001.jpg";
Run Code Online (Sandbox Code Playgroud)
你得到
"/root/sdcard/Pictures"
Run Code Online (Sandbox Code Playgroud) 我是firebase存储的新手.就这样我可以学习它,我做了一个简单的应用程序,有一个按钮和一个ImageView.当我单击按钮时,图像(from drawable)将显示在ImageView上.我还编写了在Firebase上上传图像的代码,但是onAddFailureListener给出消息的异常消息User没有访问此对象的权限.我该怎么办 ?
package com.example.asad.save_photo;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.net.Uri;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageMetadata;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.io.ByteArrayOutputStream;
import java.io.File;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://savephoto-a1cc3.appspot.com");
final StorageReference mountainsRef = storageRef.child("asad"); …Run Code Online (Sandbox Code Playgroud) 我有一个启动器Activity加载和调整大位图的大小,因为它是打开时的背景.
每当按下后退按钮时,Activity就是destroyed.但我认为记忆尚未公布.
当我打开应用程序时,点击后退按钮再次打开它(反复),我会得到一个OutOfMemoryError.
我这个新手的问题,对不起,但我不知道我怎么释放每当记忆Activity是destroyed?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
//MARK - movingBackgroundImageView
movingBackgroundImageView = (ImageView) findViewById(R.id.movingBackgroundImageView);
movingBackgroundImageView.setColorFilter(Color.argb(255, 255, 255, 255));
movingBackgroundImageView.setScaleType(ImageView.ScaleType.MATRIX);
movingBackgroundImageView.setAlpha(0.28f);
prepareBackgroundAnimation();
}
private void prepareBackgroundAnimation() {
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
screenWidth = displaymetrics.widthPixels;
screenHeight = displaymetrics.heightPixels;
movingImageHeight = displaymetrics.heightPixels;
movingImageWidth = 1920.0 / 1080.0 * movingImageHeight;
bitmapImage = BitmapFactory.decodeResource(this.getResources(), R.drawable.moving_background_image);
scaledBitmap = bitmapImage.createScaledBitmap(bitmapImage, (int) movingImageWidth, (int) movingImageHeight, false);
movingBackgroundImageView.setImageBitmap(scaledBitmap);
backgroundImageInBeginning …Run Code Online (Sandbox Code Playgroud) android out-of-memory android-memory android-studio android-bitmap
在Android studio 2.0第一次启动应用程序之后,emulator它似乎附加了运行进程.但是,如果我连接设备并想要测试应用程序,则设备选择器对话框不会显示.我尝试了即时运行,简单运行,检查配置(它设置为显示选择器对话框),但所有更改都是对emulator应用程序进行的.
如何启动应用程序设备而不关闭emulator和丢失即时运行" **connection**" emulator?
我正在尝试在我的现有Android应用程序中添加Android 6.0支持.我曾经用过SYNCADAPTER同步数据.它的工作正常,直到API 22.但是在23(ANDROID 6.0)中他们已经删除了Group权限AUTHENTICATE_ACCOUNTS.
我找到了如何获得运行时权限的示例,我尝试过同样AUTHENTICATE_ACCOUNTS但它不起作用.
我也找到了一个答案,是否有任何诀窍与AUTHENTICATE_ACCOUNTS答案相同?
我发现删除权限列表overhere.所以,如果我的应用程序使用列出的权限.在这种情况下,任何应用程序在Android M(6.0)中都有效吗?
android android-permissions android-runtime android-6.0-marshmallow
android ×10
instant-run ×3
directory ×1
firebase ×1
google-play ×1
java ×1
path ×1
settings ×1
toolbar ×1