我正在尝试为我的 android 应用程序中的不同路径设置动画矢量路径以进行测试,但它无法正常工作。屏幕上不显示动画,也不显示任何动画。
我的矢量文件是:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="8dp"
android:height="5dp"
android:viewportWidth="8"
android:viewportHeight="5">
<path
android:name="redot"
android:pathData="M2.5,2.5L6,2.5"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#E61B1B"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
</vector>
Run Code Online (Sandbox Code Playgroud)
我的 VectorAnimation 文件是:
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:targetApi="lollipop"
android:drawable="@drawable/ic_reddot">
<target
android:animation="@anim/redanim"
android:name="redot"/>
</animated-vector>
Run Code Online (Sandbox Code Playgroud)
我在 anim 文件夹中的动画文件是:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="10000"
android:propertyName="pathData"
android:valueFrom="M2.5,2.5L6,2.5"
android:valueTo="M2.5,2.5L31,2.5"
android:valueType="pathType" />
</set>
Run Code Online (Sandbox Code Playgroud)
最后我的 MainActivityCode 如下:
public class MainActivity extends AppCompatActivity {
private TextView testObj;
private ImageView reddot;
private AnimatedVectorDrawable animation;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// …Run Code Online (Sandbox Code Playgroud) 我正在开发一个聊天应用程序,我想存储我的消息的时间戳。我的消息数据类是:
import com.google.firebase.firestore.ServerTimestamp;
import java.util.Date;
public class messgaesDataClass {
private String messageText;
private int messageStatus;
private String messagefrom;
private @ServerTimestamp Date timestamp;
public messgaesDataClass(String messageText, int messageStatus, String messagefrom, Date time) {
this.messageText = messageText;
this.messageStatus = messageStatus;
this.messagefrom = messagefrom;
this.time = time;
}
public messgaesDataClass() {
}
public String getMessageText() {
return messageText;
}
public void setMessageText(String messageText) {
this.messageText = messageText;
}
public int getMessageStatus() {
return messageStatus;
}
public void setMessageStatus(int messageStatus) {
this.messageStatus = messageStatus; …Run Code Online (Sandbox Code Playgroud) 我正在使用 Firestore 数据库创建聊天模块。以下是我侦听新消息的侦听器代码:
mDb.collection("Users_Collection").document(mAuth.getUid()).collection("Recipients")
.document(psychichObj.getUid()).collection("Messages").orderBy("time").limit(30)
.addSnapshotListener(MetadataChanges.INCLUDE, new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
if (e==null){
for (DocumentChange dc:queryDocumentSnapshots.getDocumentChanges()){
switch (dc.getType()){
case ADDED:
Log.d("chatevents", "onEvent:Added ");
messgaesDataClass msg = dc.getDocument().toObject(messgaesDataClass.class);
messages.add(msg);
chatAdapter.notifyDataSetChanged();
messagesRecycler.smoothScrollToPosition(messages.size());
break;
case REMOVED:
Log.d("chatevents", "onEvent:Removed ");
case MODIFIED:
Log.d("chatevents", "onEvent:Modiefied ");
}
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
当我发送消息时,我想知道如何侦听本地缓存中的 msg 对象或其元数据处于挂起状态但尚未发送到服务器的消息?