Aplicacion Mensaje
Aplicacion Mensaje
Tecnológico Cuicalli
Android Studio
Proyecto Mensaje
import android.app.Activity;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import androidx.annotation.NonNull;
private KeyboardUtils() {
}
imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
0);
}
}
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.widget.NestedScrollView;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupViews();
}
import androidx.annotation.NonNull;
@SuppressWarnings("unused")
public class TextViewUtils {
private TextViewUtils() {
}
@Override
public void onTextChanged(CharSequence s, int start, int
before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
listener.afterTextChanged(s);
}
});
}
public static void addBeforeTextChangedListener(@NonNull TextView
textView,
@NonNull
BeforeTextChangedListener listener) {
textView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int
count, int after) {
listener.beforeTextChanged(s, start, count, after);
}
@Override
public void onTextChanged(CharSequence s, int start, int
before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
@Override
public void onTextChanged(CharSequence s, int start, int
before, int count) {
listener.onTextChanged(s, start, before, count);
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
@Override
public void onTextChanged(CharSequence s, int start, int
before, int count) {
if (onTextChangedListener != null) {
onTextChangedListener.onTextChanged(s, start, before,
count);
}
}
@Override
public void afterTextChanged(Editable s) {
if (afterTextChangedListener != null) {
afterTextChangedListener.afterTextChanged(s);
}
}
});
}
Estas serian las 3 clases de java que se ocuparan para este proyecto.
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
colors.xml
dimens.xml
<resources>
<dimen name="main_horizontal_margin">8dp</dimen>
<dimen name="main_vertical_margin">16dp</dimen>
</resources>
integers.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="main_txtMessage_maxLines">5</integer>
</resources>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ScrollView</string>
<string name="main_btnSend">Send</string>
<string name="main_txtMessage">Message</string>
<string name="main_lblTitle">Messages</string>
<string name="main_log_message">[%1$s] %2$s\n\n"</string>
</resources>
styles.xml
<resources>
</resources>
<TextView
android:id="@+id/lblTitle"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/main_horizontal_margin"
android:layout_marginStart="@dimen/main_horizontal_margin"
android:layout_marginTop="@dimen/main_vertical_margin"
android:text="@string/main_lblTitle"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<androidx.core.widget.NestedScrollView
android:id="@+id/scvText"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/main_horizontal_margin"
android:layout_marginTop="@dimen/main_vertical_margin"
app:layout_constraintBottom_toTopOf="@+id/llPanel"
app:layout_constraintLeft_toLeftOf="@+id/lblTitle"
app:layout_constraintRight_toRightOf="@+id/lblTitle"
app:layout_constraintTop_toBottomOf="@+id/lblTitle"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1">
<TextView
android:id="@+id/lblText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:id="@+id/llPanel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/primary_light"
android:paddingBottom="@dimen/main_horizontal_margin"
android:paddingEnd="@dimen/main_horizontal_margin"
android:paddingStart="@dimen/main_vertical_margin"
android:paddingTop="@dimen/main_horizontal_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1">
<EditText
android:id="@+id/txtMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:hint="@string/main_txtMessage"
android:scrollHorizontally="false"
android:maxLines="@integer/main_txtMessage_maxLines"
android:imeOptions="actionDone"
android:inputType="textImeMultiLine"
tools:ignore="Autofill">
<requestFocus />
</EditText>
<ImageView
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/main_horizontal_margin"
android:contentDescription="@string/main_btnSend"
android:padding="@dimen/main_horizontal_margin"
android:tint="@color/ic_send_tint"
android:focusable="true"
android:clickable="true"
app:srcCompat="@drawable/ic_send_black_24dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
backup_descriptor.xml
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Exclude specific shared preferences that contain GCM
registration Id -->
</full-backup-content>
backup_rules.xml
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
data_extraction_rules.xml
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as
necessary.
See https://developer.android.com/about/versions/12/backup-
restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed
up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
android:fullBackupContent="@xml/backup_descriptor">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>