提交 871d3e9f 编写于 作者: 门心叼龙's avatar 门心叼龙

map touch add

上级 1f3f39e5
......@@ -38,10 +38,10 @@ public class MapTouchActivity extends AppCompatActivity {
mBlogMapView.onCreate(savedInstanceState);
init();
initListener();
}
public void init() {
public void initListener() {
//设置BlogScrollView的透明部分的监听器
mBlogScrollView.setTransViewTouchListener(new BlogTransView.OnTouchEventListener() {
@Override
......
......@@ -72,8 +72,6 @@ public class BlogTransView extends RelativeLayout {
mBtnZoomChangeListener = listener;
}
public void setBtnMapZoomChecked(boolean b) {
if (mBtnMapZoom != null) {
mBtnMapZoom.setChecked(b);
......@@ -89,7 +87,6 @@ public class BlogTransView extends RelativeLayout {
return false;
}
}
public void setDispatchEventListener(DispatchEventListener dispatchEventListener) {
mDispatchEventListener = dispatchEventListener;
}
......
package com.android.touchevent.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import com.android.touchevent.R;
/**
* Description: <FatArrowView><br>
* Author: gxl<br>
* Date: 2019/4/9<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public class FatArrowView extends RelativeLayout {
public static final String TAG = FatArrowView.class.getSimpleName();
private CheckBox mCheckBox;
private CompoundButton.OnCheckedChangeListener mChangeListener;
public void setChangeListener(CompoundButton.OnCheckedChangeListener changeListener) {
mChangeListener = changeListener;
}
public FatArrowView(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(context, R.layout.view_usecar_fat_arrow,this);
mCheckBox = findViewById(R.id.check_trip_expend);
mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(mChangeListener != null){
mChangeListener.onCheckedChanged(buttonView,isChecked);
}
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return mCheckBox.onTouchEvent(event);
}
}
package com.android.touchevent.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.touchevent.R;
/**
* Description: <SettingBarView><br>
* Author: gxl<br>
* Date: 2019/3/4<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public class SettingBarView extends RelativeLayout {
private ImageView imgLeftIcon;
private TextView txtSetTitle;
private EditText txtSetContent;
private ImageView imgRightIcon;
private RelativeLayout layoutSettingBar;
private OnClickSettingBarViewListener mOnClickSettingBarViewListener;
private OnClickRightImgListener mOnClickRightImgListener;
private boolean isEdit = false;//是否需要编辑
public interface OnClickSettingBarViewListener {
void onClick();
}
public interface OnClickRightImgListener {
void onClick();
}
public void setOnClickRightImgListener(OnClickRightImgListener onClickRightImgListener) {
mOnClickRightImgListener = onClickRightImgListener;
}
public void setOnClickSettingBarViewListener(OnClickSettingBarViewListener onClickSettingBarViewListener) {
mOnClickSettingBarViewListener = onClickSettingBarViewListener;
}
public SettingBarView(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(context, R.layout.view_setting_bar, this);
layoutSettingBar = findViewById(R.id.layout_setting_bar);
imgLeftIcon = findViewById(R.id.img_left_icon);
txtSetTitle = findViewById(R.id.txt_set_title);
txtSetContent = findViewById(R.id.txt_set_content);
imgRightIcon = findViewById(R.id.img_right_icon);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SettingBarView);
boolean isVisableLeftIcon = typedArray.getBoolean(R.styleable.SettingBarView_set_left_icon_visable, false);
boolean isVisableRightIcon = typedArray.getBoolean(R.styleable.SettingBarView_set_right_icon_visable, false);
String title = typedArray.getString(R.styleable.SettingBarView_set_title);
String hint = typedArray.getString(R.styleable.SettingBarView_set_content_hint);
String content = typedArray.getString(R.styleable.SettingBarView_set_content);
int rightIcon = typedArray.getResourceId(R.styleable.SettingBarView_set_right_icon, 0);
int leftIcon = typedArray.getResourceId(R.styleable.SettingBarView_set_left_icon, 0);
imgLeftIcon.setVisibility(isVisableLeftIcon ? View.VISIBLE : View.GONE);
txtSetTitle.setText(title);
txtSetContent.setHint(hint);
txtSetContent.setText(content);
imgRightIcon.setVisibility(isVisableRightIcon ? View.VISIBLE : View.GONE);
if (leftIcon > 0) {
imgLeftIcon.setImageResource(leftIcon);
}
if (rightIcon > 0) {
imgRightIcon.setImageResource(rightIcon);
}
imgRightIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mOnClickRightImgListener != null) {
mOnClickRightImgListener.onClick();
}
}
});
layoutSettingBar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mOnClickSettingBarViewListener != null) {
mOnClickSettingBarViewListener.onClick();
}
}
});
}
public void setContent(String value) {
if (txtSetContent != null && !TextUtils.isEmpty(value)) {
txtSetContent.setText(value);
}
}
public String getContent() {
if (txtSetContent != null) {
return txtSetContent.getText().toString();
}
return null;
}
public void enableEditContext(boolean b) {
isEdit = b;
if (txtSetContent != null) {
txtSetContent.setEnabled(b);
}
}
public void showImgLeftIcon(boolean show) {
if (imgLeftIcon != null) {
imgLeftIcon.setVisibility(show ? View.VISIBLE : View.GONE);
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return !isEdit;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return layoutSettingBar.onTouchEvent(event);
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/usecar_icon_fold" android:state_checked="true"/>
<item android:drawable="@mipmap/usecar_icon_unfold" android:state_checked="false"/>
<item android:drawable="@mipmap/usecar_icon_unfold"/>
</selector>
\ No newline at end of file
......@@ -10,7 +10,6 @@
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
<RelativeLayout
......@@ -26,20 +25,16 @@
android:layout_height="250dp"
android:layout_alignParentTop="true"
/>
<com.android.touchevent.view.BlogScrollView
android:id="@+id/view_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.android.touchevent.view.BlogTransView
android:id="@+id/view_blog_trans"
android:layout_width="match_parent"
......@@ -53,7 +48,6 @@
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
......@@ -61,7 +55,6 @@
android:paddingLeft="16dp"
android:paddingRight="16dp"
>
<TextView
android:id="@+id/txt_trip_title"
android:layout_width="wrap_content"
......@@ -224,7 +217,6 @@
android:padding="10dp"
android:text="RxJava线程切换之subscribeOn和observeOn详解"
/>
</LinearLayout>
<View
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/layout_setting_bar"
android:layout_width="match_parent"
android:layout_height="44dp"
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="5dp"
android:paddingRight="10dp"
android:background="#FFFFFF"
>
<ImageView
android:id="@+id/img_left_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/usecar_icon_star"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
/>
<TextView
android:id="@+id/txt_set_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:textColor="#333333"
android:layout_toRightOf="@+id/img_left_icon"
android:layout_centerVertical="true"
/>
<EditText
android:id="@+id/txt_set_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="#333333"
android:layout_toRightOf="@+id/txt_set_title"
android:layout_toLeftOf="@+id/img_right_icon"
android:layout_centerVertical="true"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:enabled="false"
android:background="@null"
android:singleLine="true"
android:ellipsize="end"
/>
<ImageView
android:id="@+id/img_right_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/usecar_list_icon_into"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_usecar_arrow"
android:layout_width="40dp"
android:layout_height="40dp"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="MissingDefaultResource">
<CheckBox
android:id="@+id/check_trip_expend"
android:layout_width="12dp"
android:layout_height="7dp"
android:background="@drawable/bg_usecar_arrow"
android:button="@null"
android:layout_centerInParent="true"
/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SettingBarView">
<attr name="set_left_icon_visable" format="boolean"/>
<attr name="set_left_icon" format="reference"/>
<attr name="set_title" format="string"/>
<attr name="set_content" format="string"/>
<attr name="set_content_hint" format="string"/>
<attr name="set_right_icon_visable" format="boolean"/>
<attr name="set_right_icon" format="reference"/>
</declare-styleable>
</resources>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册