Skip to content

Instantly share code, notes, and snippets.

@Florin415
Created April 12, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Florin415/ed52c252d7bc789e7ed04ee1e6549f98 to your computer and use it in GitHub Desktop.
Save Florin415/ed52c252d7bc789e7ed04ee1e6549f98 to your computer and use it in GitHub Desktop.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/lol">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:padding="16dp"
android:text="YOU"
android:textColor="#FFFFFF"
android:textSize="14sp" />
<TextView
android:id="@+id/my_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:paddingBottom="24dp"
android:text="0"
android:textColor="#000000"
android:textSize="56sp" />
<Button
android:id="@+id/pentakill"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addFiveKillsForYOU"
android:text="Penta Kill" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addFourKillsForYOU"
android:text="Quadra KIll" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addThreeKillsForYOU"
android:text="Triple Kill" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addTwoKillsForYOU"
android:text="Double KILL" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addOneKillForYOU"
android:text="1 KILL " />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:background="#F44336" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:padding="16dp"
android:text="YOUR FRIEND"
android:textColor="#FFFFFF"
android:textSize="14sp" />
<TextView
android:id="@+id/your_friend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:paddingBottom="24dp"
android:text="0"
android:textColor="#000000"
android:textSize="56sp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addFiveKillsForYOURFriend"
android:text="PENTA KILL" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:onClick="addFourKillsForYOURFriend"
android:text="QUADRA KILL" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:onClick="addThreeKillsForYOURFriend"
android:text="TRIPLE KILL" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addTwoKillsForYOURFriend"
android:text="Double KILL" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:onClick="addOneKillForYOURFriend"
android:text="1 KILL " />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="32dp"
android:onClick="resetScore"
android:text="Reset" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.league">
<application
android:largeHeap="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
package com.example.android.league;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
int yourscore = 0;
int yourfriendsscore = 0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void addFiveKillsForYOU(View v) {
yourscore = yourscore+ 5;
displayYou(yourscore);
}
public void addFourKillsForYOU(View v) {
yourscore = yourscore+ 4;
displayYou(yourscore);}
public void addThreeKillsForYOU(View v) {
yourscore = yourscore+ 3;
displayYou(yourscore);}
public void addTwoKillsForYOU(View v) {
yourscore = yourscore+ 2;
displayYou(yourscore);}
public void addOneKillForYOU(View v) {
yourscore = yourscore+ 1;
displayYou(yourscore);}
public void addFiveKillsForYOURFriend(View v) {
yourfriendsscore = yourfriendsscore+ 5;
displayHim(yourfriendsscore);}
public void addFourKillsForYOURFriend(View v) {
yourfriendsscore = yourfriendsscore+ 4;
displayHim(yourfriendsscore);}
public void addThreeKillsForYOURFriend(View v) {
yourfriendsscore = yourfriendsscore+ 3;
displayHim(yourfriendsscore);}
public void addTwoKillsForYOURFriend(View v) {
yourfriendsscore = yourfriendsscore+ 2;
displayHim(yourfriendsscore);}
public void addOneKillForYOURFriend(View v) {
yourfriendsscore = yourfriendsscore+ 1;
displayHim(yourfriendsscore);}
public void displayHim(int yourfriendsscore) {
TextView yourfriendsscoreView = (TextView) findViewById(R.id.your_friend);
yourfriendsscoreView.setText(String.valueOf(yourfriendsscore));}
public void displayYou(int yourscore) {
TextView yourscoreView = (TextView) findViewById(R.id.my_score);
yourscoreView.setText(String.valueOf(yourscore));}
public void resetScore(View v) {
int yourscore = 0;
int yourfriendsscore = 0;
displayYou(yourscore);
displayHim(yourfriendsscore);
}
}
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#F44336</item>
<item name="colorPrimaryDark">#F44336</item>
<item name="colorAccent">#F44336</item>
<item name="colorButtonNormal">#F44336</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment