我有一个返回json字符串的服务器:
{"pId": "ChIJ2Vn0h5wOlR4RsOSteUYYM6g"}
Run Code Online (Sandbox Code Playgroud)
现在,我可以使用jackson将其反序列化为一个名为pId的变量的对象,但我不希望该变量被称为pId,我宁愿将其反序列化为placeId.
android java中的当前对象:
public class Place {
private String pId;
}
Run Code Online (Sandbox Code Playgroud)
我希望对象看起来像什么:
public class Place {
private String placeId;
}
Run Code Online (Sandbox Code Playgroud)
如果我将对象的变量更改为placeId,则jackson将无法反序列化JSON,因为属性名称不再匹配.
是否有一个jackson注释我可以用来将java对象中的"placeId"变量映射到从服务器返回的JSON字符串变量"pId"?
我正在使用Google Maps API for Android.我将我的代码从我的桌面推送到Github上,然后当我想在旅途中处理代码时,将它从Github下载到我的笔记本电脑上.
就Google Maps API而言,我需要将API密钥放在Android清单中,如下所示:
<application>
...
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
</application>
Run Code Online (Sandbox Code Playgroud)
现在,因为我有两个不同的调试证书(笔记本电脑上的那个和桌面上的那个),谷歌的API密钥也会有所不同,因为来自调试证书的SHA-1指纹会有所不同.
如何在两台PC上保持这种独特性?
我认为有必要在git上跟踪android清单,因为这是任何应用程序中非常重要的组件,但现在我每次推送时如何避免API密钥冲突?
我有一个 spring boot gradle 应用程序,可以通过执行以下操作在我的 PC 上成功运行:
heroku local
Run Code Online (Sandbox Code Playgroud)
当我去的时候它也可以成功部署在heroku上:
git push heroku master
Run Code Online (Sandbox Code Playgroud)
这是我的结果:
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 596 bytes | 0 bytes/s, done.
Total 9 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/heroku/heroku-buildpack-gradle... done
remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle …Run Code Online (Sandbox Code Playgroud) 我collapsingToolbarLayout在折叠模式和展开模式下都显示了用户名.
展开时看起来像这样:
半坍塌时看起来像这样:
您可以看到白色文本在展开模式下与背景图像不能很好地协同工作.
通常为了提高文本的清晰度,如果这是一个textview,我通常会setShadowLayer:http://developer.android.com/reference/android/widget/TextView.html#setShadowLayer( float,%20float,%20float,% 20int)
在这种情况下,因为它是a collapsingToolbarLayout,它不是a textview,所以看起来该方法不可用于在文本后面设置阴影.
有没有人知道一种方法可以增加文本的澄清,collapsingToolbarLayout例如可能在文本中collapsingToolbarLayout添加阴影或添加阴影?
这段代码工作似乎在android api 16 - 22中工作但在api 23中不起作用.我只是试图在其中显示一个带有选项的popupwindow并将背景调暗到popupwindow下面:
WindowPopUp windowPopUp =
new WindowPopUp(mContext, mPlaces.get(position), position, fromSearch);
windowPopUp.showAtLocation(v, Gravity.CENTER, 0, 0);
View parent = (View) windowPopUp.getContentView().getParent();
//dim the window in the background
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams p = (WindowManager.LayoutParams) parent.getLayoutParams();
p.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
p.dimAmount = 0.4f;
wm.updateViewLayout(parent, p);
Run Code Online (Sandbox Code Playgroud)
运行此代码会导致错误:
03-18 21:55:19.674 8814-8814/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 8814
java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.view.WindowManager$LayoutParams
at com.bemyapp.adapter.OuterPlaceAdapter$5.onLongClick(OuterPlaceAdapter.java:400)
at android.view.View.performLongClick(View.java:5237)
at android.view.View$CheckForLongPress.run(View.java:21121)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417) …Run Code Online (Sandbox Code Playgroud) android layoutparams android-popupwindow android-6.0-marshmallow
我一直在看Facebook评论活动:
我一直想知道他们如何设法使edittext的大小从一行增加到最多4行,与此同时,包含这些帖子的recyclerview也向上调整并减小了大小。当您输入文字时,这会自动发生。
我正在尝试通过执行以下操作自己复制其布局,但我不能显示多于2行。它一直将自身限制为“发送”箭头的大小,但在下面的示例中,edittext永远不会超过recyclerview。
以下是我的xml布局代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/like_box"
android:text="Number of Likes goes here"
android:maxLines="1"
android:minLines="1"
android:layout_margin="16dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:id="@+id/divider"
android:layout_below="@+id/like_box"
android:background="@color/half_black"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_below="@+id/divider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/commenttext" />
<View
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:id="@+id/divider2"
android:layout_below="@+id/my_recycler_view"
android:background="@color/half_black"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/commenttext"
android:layout_toLeftOf="@+id/send"
android:background="@null"
android:paddingLeft="16dp"
android:textSize="16sp"
android:hint="Add a comment here"
android:layout_alignTop="@+id/send"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/send"
android:src="@drawable/ic_action_send_now"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
有谁知道正确的xml布局代码是什么,以确保输入文本时,edittext和recyclerview都向上调整?我认为这只是简单的事情,例如将“ wrap_content”设置为我已经完成的edittext,但仍然无法正确调整。
Anoop M的答案似乎与我想做的最接近,但是recyclerview的调整不正确-请参见下图。想象一下,如果屏幕的蓝色部分充满了文本,那么当您输入4行以上时,edittext最终将文本隐藏在蓝色部分中。edittext似乎遍历了recyclerview。在Facebook应用程序上不会发生这种情况,当edittext大小增加时,随着recyclerview向上调整,注释将完全显示。
当您刷新 facebook 页面时,SwipeRefreshLayout似乎被放置在活动类中并从屏幕顶部下降:
看起来RecyclerView像是在它下面的东西被刷新了。您还需要一直滚动到屏幕顶部,然后SwipeRefreshLayout才会自行激活 - 因此,如果ImageView工具栏中的 没有出现在屏幕顶部,那么当您向下滑动时,您实际上只是在滚动RecyclerView. 在下面的截图中,我们可以看到顶部ImageView是不可见的,所以我们只是滚动我们的 recyclerview。
我正在尝试通过在 xml 中执行以下操作来在我的应用程序中实现类似的东西,这看起来类似于我上面发布的第一个 Facebook 屏幕截图 - 我的活动具有从顶部出现的“swipeRefresh circle icon”并遵循标准布局 xml设置toolbar一个ImageView:
主要活动 XML:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinatorlayout"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/appbar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
android:background="@color/white"
app:expandedTitleTextAppearance="@color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<ImageView
android:id="@+id/backdrop"
android:contentDescription="@string/photo"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="192dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) android facebook android-fragments android-activity swiperefreshlayout
我正在使用以下站点中的压缩类:http://voidcanvas.com/whatsapp-like-image-compression-in-android/
这是我的压缩类,对原始类进行了很少的修改:
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.media.ExifInterface;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import timber.log.Timber;
//http://voidcanvas.com/whatsapp-like-image-compression-in-android/
public class ImageCompressor {
public ImageCompressor() {}
public static String compressImage(String imagePath, Context context) {
Bitmap scaledBitmap = null;
String filename = "compressed_" +imagePath.substring(imagePath.lastIndexOf("/")+1);
BitmapFactory.Options options = new BitmapFactory.Options();
// by setting this field as true, the actual bitmap pixels are not loaded in the memory. Just the bounds are loaded. If
// you …Run Code Online (Sandbox Code Playgroud) 这是whatsapp应用程序。请注意,当您选择一个选项卡时,“CONTACTS”一词是白色的,而其他词 CALLS 和 CHATS 的 alpha 值可能为 50%:
他们是如何做到这一点的?
我想做一些类似的事情,但用图标而不是文字,但原理应该是一样的。我已经用我的 TabLayout 完成了以下操作:
TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
tabLayout.setTabGravity(tabLayout.GRAVITY_FILL);
tabLayout.setupWithViewPager(viewPager);
tabLayout.getTabAt(0).setIcon(R.drawable.icon1);
tabLayout.getTabAt(1).setIcon(R.drawable.icon2);
tabLayout.getTabAt(2).setIcon(R.drawable.icon3);
Run Code Online (Sandbox Code Playgroud)
这是我的 tabLayout 的 xml:
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cccccc"
app:tabPaddingStart="-1dp"
app:tabPaddingEnd="-1dp" />
Run Code Online (Sandbox Code Playgroud)
我还阅读了此线程:如何在使用 TabLayout 时更改选项卡背景颜色?但这不完全是我想要的。
该线程表示,当您选择或取消选择它时,它会更改整个选项卡的颜色。这意味着您会将图标后面的整个背景更改为不同的颜色,而我只希望图标具有较低的不透明度,而不是背景和图标具有较低的不透明度。
Whatsapp 没有这样做 - 你只能看到“呼叫”这个词被设置为较低的不透明度,而不是这个词背后的背景。
希望这张照片可以解释一下我想做什么.请记住,textview和recyclerview都是FRAMELAYOUT的ViewGroup.
我想match_parent对FRAMELAYOUT进行回收查看.该textview显示单词"邻居"必须在recyclerview的顶部.您无法从图像中看到它,但是它textview具有alpha0.5,因此它是半透明的.
我想要做的是让recyclerview viewholders你在图片中看到的深绿色项目,在高度下开始textview.这样,当用户滚动时recyclerview,项目将在半透明下正常滚动textview.
有没有办法确保recyclerview中的第一个项目从recyclerview的顶部(即textview的高度)稍微开始,以便可以实现这种效果?
android ×8
facebook ×2
java ×2
android-collapsingtoolbarlayout ×1
android-xml ×1
git ×1
heroku ×1
image ×1
json ×1
layoutparams ×1
spring ×1
spring-boot ×1
textview ×1